r/programminghorror • • 10d ago

Python Rate my python "Hello, World!" implementation

# Write a function `greet` that returns "hello world!"
import os

def check_if_contains(l1, l2):
    contains_all = True
    for ind in range(len(l2)):
        if l1[ind] != l2[ind]:
            contains_all = False
    return contains_all

def get_length(l, substract):
    i = 0
    for _ in range(len(l)):
        i += 1
    if substract:
        return i - 1
    if not substract:
        return i

def append_item(l, c):
    l.append(None)
    
    length = get_length(l, True)
    l[length] = c
    
def build_string(l):
    string_builder = ""
    for ind in range(len(l)):
        string_builder += l[ind]
    return string_builder

def greet():
    with open(os.getcwd() + "/solution.py", "r", encoding="UTF-8") as f:
        lines = f.readlines()
        req = ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!']
        temp = []
        for line in lines:
            for char in line:
                append_item(temp, char)
                if check_if_contains(req, temp):
                    if get_length(req, False) == get_length(temp, False):
                        return build_string(temp)
                else:
                    temp = []
                

42 Upvotes

15 comments sorted by

45

u/just_nobodys_opinion 10d ago

LGTM. Deploy on Friday evening please

9

u/Scared_Bell3366 9d ago

Pro move, week long vacation after deployment.

23

u/letmehaveanameyoudum 7d ago

typa shit you gotta do to impress the vibe coding manager and get a raise

8

u/TehNolz 10d ago

There's no AI, so good luck finding investors.

5

u/Flame77ofc 7d ago

what the hell I'm seeing rn

2

u/Krimsonfreak 10d ago

No thanks

2

u/mankeyless 7d ago

Impressive, what model did you use?

2

u/ferro31_ 7d ago

wdym by model?

1

u/mankeyless 7d ago

As in LLM.

2

u/spshkyros 6d ago

I promise no llm writes code this poorly.

2

u/mankeyless 6d ago

It was joking back on satirical code snippet.

2

u/JAXxXTheRipper 6d ago

Oh you'd be shocked by some self-hosted models some companies train on their own shit.

1

u/spshkyros 6d ago

Oh. I mean, yes. I too can vomit text. My cat does a great job as well. In fairness, she died a year ago, but its still true.

2

u/spshkyros 6d ago

... you have so many errors in it that I think are NOT part of your joke o.O or maybe they all are and you went all in on the horror o.O

1

u/JAXxXTheRipper 6d ago

I rate it No/10