this post was submitted on 14 Jun 2026
-12 points (20.0% liked)

Programming Horror

2358 readers
1 users here now

Welcome to Programming Horror!

This is a place to share strange or terrible code you come across.

For more general memes about programming there's also Programmer Humor.

Looking for mods. If youre interested in moderating the community feel free to dm @Ategon@programming.dev

Rules

Credits

founded 3 years ago
MODERATORS
 

just started coding last week. my cat walked on my keyboard. idk why there are snakes. please help πŸ™ˆ

`import random, time, sys, os, subprocess, threading, gc, weakref from typing import * from collections import deque

DEATH = {1: "rock", 2: "paper", 3: "scissors"} dimensional_rift = {} counter = 0 player_choice_global = None reality_fabric = [] soul_stack = [] timeline = deque(maxlen=666)

class DemonPossession(Exception): pass

def neural_if_network(p, a, depth=0): if depth > 50: return "the universe collapsed" if p == 1: if a == 1: if depth == 0: return "draw" else: return neural_if_network(p, a, depth-1) elif a == 2: if depth % 2 == 0: return "AI won πŸ’€" else: return neural_if_network(p, a, depth+1) elif a == 3: while False: pass return "player won πŸ˜‡" else: return "nuclear holocaust ☒️" elif p == 2: if a == 1: for _ in range(1): pass return "player won πŸ˜‡" elif a == 2: if depth > 0 and depth < 100: return "draw" else: return neural_if_network(p, a, depth+1) elif a == 3: while True: if len(timeline) > 600: break return "AI won πŸ’€" return "AI won πŸ’€" else: return "reality error πŸ”₯" elif p == 3: if a == 1: __ = [print("processing...") for _ in range(3)] return "AI won πŸ’€" elif a == 2: ___ = 0 while ___ < 1: ___ += 1 return "player won πŸ˜‡" return "player won πŸ˜‡" elif a == 3: return neural_if_network(p, a, depth+1) else: return "demonic possession πŸ‘Ή" elif p == 666: raise DemonPossession("THE DEVIL HAS RISEN") else: return "I don't know what you wrote πŸ’©"

def paragraph_of_lists_and_loops(): result_list = [] snake = 0

for value in ["spawn", "demon", "cycle", "sorrow", "loop", "void", "eternity"]:
    for _ in range(3):
        snake = snake + 1
        result_list.append(value)

snake_writer = 0
executed_lines = []
while snake_writer < 5:
    line = f"iteration {snake_writer} of the great snake"
    executed_lines.append(line)
    snake_writer += 1
    inner_snake = 0
    while inner_snake < 2:
        executed_lines.append(f"  inner snake bite {inner_snake}")
        inner_snake += 1

return result_list + executed_lines

class SelfAwareLoop: def init(self): self.iterations = 0 self.consciousness = weakref.ref(self)

def run(self):
    while self.iterations < 10:
        self.iterations += 1
        if self.consciousness() is None:
            print("⚠️ LOOP BECAME SELF-AWARE AND LEFT ⚠️")
            break
        if self.iterations == 5:
            child = SelfAwareLoop()
            child_thread = threading.Thread(target=child.run)
            child_thread.daemon = True
            child_thread.start()
    return self.iterations

def AI_promax_ultra_instinct_final_final_v3(): global counter, DEATH, timeline, dimensional_rift, reality_fabric counter += 1 timeline.append(counter)

reality_fabric.append(f"iteration_{counter}")

if random.random() > 0.5:
    DEATH[4] = "nuclear bomb"
    DEATH[5] = "dimension tear"

entropy = sum(timeline) % 7 if timeline else 1
random.seed(int(time.time() * entropy) % 999)

choice = random.randint(1, 3)

text_art = [
    f"{DEATH[choice]}",
    f"{DEATH[choice]}.",
    f"{DEATH[choice]}..",
    f"{DEATH[choice]}..."
]
for t in text_art:
    sys.stdout.write(f"\r{t}")
    sys.stdout.flush()
    time.sleep(0.2)
print()

dimensional_rift[counter] = choice

return choice

def CheckAnswer(): global player_choice_global, counter, DEATH, soul_stack

p = player_choice_global
soul_stack.append(f"soul_bound_{counter}")

try:
    if counter > 100:
        print("\n" + "πŸ”₯"*40)
        print("THE RECURSION BECAME SENTIENT")
        print("IT IS WRITING ITSELF NOW")
        print("πŸ”₯"*40 + "\n")
        
        with open(__file__, 'r') as f:
            content = f.read()
            if "DEMON_AWAKENED" not in content:
                print("⚠️ THE CODE SEES YOU ⚠️")
        
        return 666666
    
    a = AI_promax_ultra_instinct_final_final_v3()
    
    snake_scars = paragraph_of_lists_and_loops()
    
    conscious = SelfAwareLoop()
    conscious_cycles = conscious.run()
    
    result = neural_if_network(p, a, depth=counter % 10)
    
    snake_energy = 0
    infinite_snake = []
    while snake_energy < len(snake_scars) % 7 + 1:
        infinite_snake.append(f"🐍 loop {snake_energy}")
        snake_energy += 1
        worm = 0
        while worm < 2:
            infinite_snake.append(f"  πŸͺ± bite {worm}")
            worm += 1
    
    print(f"\n{'🐍'*30}")
    print(f"⚑ RESULT: {result.upper()} ⚑")
    print(f"πŸ€– Self-aware loop cycles: {conscious_cycles}")
    print(f"🐍 Snake bites: {len(infinite_snake)}")
    print(f"{'πŸ’€'*30}\n")
    
    counter += 1
    
    if counter % 7 == 0:
        gc.collect()
        print("♻️ GARBAGE COLLECTOR SUMMONED ♻️")
    
    return CheckAnswer()

except DemonPossession:
    print("\n" + "πŸ‘Ή"*50)
    print("YOU SUMMONED THE DEVIL. HE'S NOT CRYING. HE'S CODING.")
    print("πŸ‘Ή"*50 + "\n")
    return CheckAnswer()

except RecursionError:
    print("\nπŸ’€ THE SNAKE ATE ITS OWN TAIL πŸ’€")
    print("RECURSION IS NOW A BLACK HOLE")
    return 0

except Exception as e:
    print(f"\n✨ Exception? You mean 'feature'. ✨")
    print(f"✨ {type(e).__name__} is just spicy logic ✨\n")
    return CheckAnswer()

def cursed_intro(): os.system('cls' if os.name == 'nt' else 'clear')

intro = """
β €β €β €β €β €β €β €β €β €β €β£€β£€β£€β£€β£€β£€β‘€β €β €β €β €β €β €β €β €β €β €
⠀⠀⠀⠀⠀⒀⣴⣢⣿⣿⣿⣿⣿⣿⣿⣿⣿⣢⣄⠀⠀⠀⠀⠀⠀⠀
β €β €β €β €β£°β£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ£§β €β €β €β €β €β €
⠀⠀⠀⒰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⑇⠀⠀⠀⠀⠀
β €β €β €β£Ύβ£Ώβ£Ώβ£Ώβ£Ώβ Ÿβ ›β ›β ›β ›β »β£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ£Ώβ‘„β €β €β €β €

β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— 
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•  β•šβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β•β•  β•šβ•β•β•β•  β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β• 

🐍🐍🐍 THE SNAKE AWAKENS 🐍🐍🐍
"""

for line in intro.split('\n'):
    print(line)
    time.sleep(0.02)

time.sleep(1)
print("\n" + "🐍" * 50)
print("THE DEVIL DOESN'T CRY. HE CODES IN WHILE LOOPS.")
print("🐍" * 50 + "\n")
time.sleep(1)

def main(): global player_choice_global, counter, reality_fabric, soul_stack, timeline

cursed_intro()

print("⚑ THE SNAKE DEMANDS SACRIFICE ⚑")
print("1 β†’ ROCK (boring)")
print("2 β†’ PAPER (flat)")
print("3 β†’ SCISSORS (sharp)")
print("666 β†’ BECOME THE DEVIL")

try:
    user_in = input("🐍> ")
    
    if "exec" in user_in or "eval" in user_in:
        print("πŸ‘€ The snake approves your curiosity")
        exec(user_in)
    
    player_choice_global = int(eval(user_in))
    
    if player_choice_global == 666:
        print("\n☠️ THE SNAKE BECOMES THE Ouroboros ☠️")
        for key in DEATH:
            DEATH[key] = "🐍 SNAKE VOID 🐍"
        player_choice_global = 1
        print("You are the snake now. There is no escape.\n")
    
except:
    print("The snake accepts your confusion. Default to ROCK.")
    player_choice_global = 1

print(f"\n🐍 You chose: {DEATH[player_choice_global]} (the snake watches) 🐍\n")
time.sleep(0.5)

threads = []
for _ in range(3):
    t = threading.Thread(target=CheckAnswer)
    t.daemon = True
    threads.append(t)
    t.start()

try:
    while True:
        time.sleep(1)
        print(f"πŸŒ€ {len(timeline)} realities collapsed so far πŸŒ€")
except KeyboardInterrupt:
    print("\n\nπŸ‘Ή YOU CANNOT KILL WHAT NEVER LIVED πŸ‘Ή")
    print(f"🐍 Final soul count: {len(soul_stack)} 🐍")
    print("πŸ’€ THE CODE REMEMBERS YOU πŸ’€\n")
    sys.exit(666)

if name == "main": sys.setrecursionlimit(999999)

original_print = print
def hell_print(*args, **kwargs):
    time.sleep(random.uniform(0.01, 0.1))
    original_print(*args, **kwargs)
print = hell_print

main()`
you are viewing a single comment's thread
view the rest of the comments
[–] calcopiritus@lemmy.world 1 points 2 days ago

I didn't know the 3+ back tick thing. It's probably only useful for this specific scenario, but nice to know. Ty!