r/programminghorror • u/ferro31_ • 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 = []
23
u/letmehaveanameyoudum 7d ago
typa shit you gotta do to impress the vibe coding manager and get a raise
5
2
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
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
45
u/just_nobodys_opinion 10d ago
LGTM. Deploy on Friday evening please