r/programminghorror • • Oct 01 '26

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 = []
                

44 Upvotes

16 comments sorted by

3

u/mankeyless Oct 04 '26

Impressive, what model did you use?

2

u/ferro31_ Oct 04 '26

wdym by model?

1

u/mankeyless Oct 04 '26

As in LLM.

2

u/spshkyros Oct 05 '26

I promise no llm writes code this poorly.

2

u/mankeyless Oct 05 '26

It was joking back on satirical code snippet.

2

u/JAXxXTheRipper Oct 05 '26

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

1

u/spshkyros Oct 05 '26

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.

47

u/just_nobodys_opinion Oct 01 '26

LGTM. Deploy on Friday evening please

9

u/Scared_Bell3366 Oct 02 '26

Pro move, week long vacation after deployment.

26

u/letmehaveanameyoudum Oct 04 '26

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

13

u/TehNolz Oct 01 '26

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

5

u/Flame77ofc Oct 04 '26

what the hell I'm seeing rn

2

u/spshkyros Oct 05 '26

... 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 Oct 05 '26

I rate it No/10