356
you are viewing a single comment's thread
view the rest of the comments
[-] joyjoy@lemm.ee 64 points 8 months ago

You call that russian roulette? This is real russian roulette. Dying is a 1/6 probability.

#!/usr/bin/env python3
import random

barrel = [0, 0, 0, 0, 0, 1]
random.shuffle(barrel)

print("Russian Roulette")
for i in barrel:
  input("Press enter to shoot")
  if i == 1:
    print("You are dead.")
    exit()
  else:
    print("Phew. You survived.")
[-] librecat@lemmy.basedcount.com 20 points 8 months ago

I love this, except for i i hate i.

[-] saroh@lemmy.world 16 points 8 months ago

And maybe the fact that you have to continue until the gun actually fires :|

[-] bhamlin@lemmy.world 10 points 8 months ago

You can ~~quit~~ control-c at any point. Sometimes, the game plays you.

[-] problematicPanther@lemmy.world 11 points 8 months ago

but it's easier than thinking of a useful variable name.

[-] kogasa@programming.dev 5 points 8 months ago
[-] Iapar@feddit.de 3 points 8 months ago
[-] finestnothing@lemmy.world 3 points 8 months ago

I always use i because I'm too lazy to type out iterator when I'm making my garbage spaghetti code that will support infrastructure for years

[-] faintwhenfree@lemmus.org 1 points 8 months ago

I like it, i for int easy to remember. I also use i, j, k as u it vectors and remember at what depth of a multidimentional array in working at.

[-] winky9827b@lemmy.world 1 points 8 months ago

You forgot the switch.

this post was submitted on 19 Feb 2024
356 points (94.9% liked)

Programmer Humor

19454 readers
770 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS