r/programminghorror
•
u/MidKnightIsOnline
•
Sep 24 '26
•
1
Python 13 year old me really liked inefficient code
3.0k
Upvotes
1.3k
u/cicciograna Sep 24 '26
Hey, you were 13 years old, and were writing code. Nobody is born already knowing all the best practices, we all grow, learn, test and slowly assimilate what is good and what is not.
And then there's those like me, whose code still sucks well into my 40s.
724
u/NiceTryAmanda Sep 24 '26
it is absolutely clear the moment you read it exactly what the code is doing and what it'll output. from that angle it's way more successful than most of the code I see in my own job
as a side note seeing "13 year old me" alongside python3 makes me feel ancient
318
u/Eric_Prozzy Sep 24 '26
Lol i did this exact same thing and also learned that
Works the same
143
u/Creepy_Jeweler_1351 Sep 24 '26
At least it is totally readable
51
u/jonathancast Sep 24 '26
Meh. I don't love the repeated string comparison, but it's probably fine. This program is ridiculously user-interaction-bound anyway.
40
u/lizenzblue_ Sep 24 '26
I worked at one of germanys biggest Software Companies and I can tell you with confidence I saw worse
107
u/Brave_Abbreviations5 Sep 24 '26
Yesterday me was dumb af
17
u/drinkmoredrano Sep 24 '26
You see inefficient code, I see a future SAP developer
14
u/Arcanium_Walker Sep 24 '26
Can be better, but you wrote this at 13 years old, so I think this is neat
60
u/Ok-Argument7176 Sep 24 '26
this is not inefficient. It's just clunky.
7
u/alexzoin Sep 24 '26
I have seen much worse.
6
u/frishki_zrak Sep 24 '26
Was this "screenshot" taken then or now? What is dad.py?
5
u/mediocrobot Sep 24 '26
What's the optimal way to do this, I wonder? (the rock paper scissors comparison specifically, not printing, randomizing, or accepting input)
5
u/MushroomSaute Sep 24 '26
But think of that beautiful +0 -48 commit you get to make now
4
u/Nixinova Sep 24 '26
Nah this is pretty good for a 13yo. Immediately readable and clear what the logic is. There's only 3x3 cases, so it's not like it's yandere level.
4
u/Silyyxx Sep 27 '26
Hey, you were 13, as long as you are not Yandere Dev who had like 50000 If statements which made his game horrible, all is good đ
1
u/internet_raider Sep 27 '26
I built a Redstone machine where to opponents play rock paper scissors in separate rooms once when I was young that worked basically just like this with nor gates so that each signal would be active for a specific outcome and then a three signal and gate for each of those. It was like the size of small Minecraft computers now because I didn't know anything about compact Redstone at the time and it took me several days.
1
u/unhinged110 Sep 28 '26
Heâs ready to be an indie dev
1
u/False-Beautiful-1246 Oct 08 '26
- Why are there so many nested IFs?
- If the user wants to play again
- "A"
6
u/Toxanium Sep 25 '26
I'm new to coding, how should you make something like this more efficient?
3
u/NothingButBadIdeas Sep 24 '26
It happens.
I look at code from a year ago, get mad and look at the git blame.
It was me. My own bad code got me upset lol.
3
u/RandalSchwartz Sep 24 '26
I'm thinking of how to solve it faster. Choices numbered 0, 1, 2. Subtract one from the other. if 0, tie. If +1 or -2, one person wins. If it's -1 or +2, other person wins.
EDIT: and I bet there's something even more direct with "mod 3" in there somewhere. :)
3
u/__SegFault__ Sep 25 '26
I really like the
== truepart, as I did this myself when I started coding too3
u/kindredseer Sep 25 '26
I think this was the training code for most LLMs đ
3
u/Code_Noob_Noodle Sep 25 '26
This makes me want to see how I wrote c++ đ around this age (my first language)
3
u/tactical_index Sep 27 '26
it's not inefficient code if you didn't know the efficient way
4
u/fuj1n Sep 24 '26
Unless I'm missing something, because you're re-calculating the cpuinput at the end of each if statement, I think it is possible to get all 3 responses at once for any one choice.
For example, if the player chooses rock and the CPU picks scissors, then rock, then paper, it will tell you that you won, tied and then lost all for your one answer.
2
u/The-Bytemaster Sep 24 '26
You were young andalso you learned.
2
u/burntcandy Sep 24 '26
Needlessly verbose, but not inefficient
2
u/not_a_bug_a_feature Sep 24 '26
It's called learning, friend!
2
u/Previous-Ant2812 Sep 24 '26
This just shows that you know how to learn and improve
2
u/theChaosBeast Sep 24 '26
Could be worse
2
u/scmr2 Sep 25 '26
Honestly, I wish I wrote code like this when I was 13 years old... I was not writing code when I was 13 years old.Â
2
u/Prudent_Ad_4120 Sep 25 '26
I once wanted to write a converter from text to binary, guess how I did that đ
(Spoiler: it was like a=0000 b=0001 c=0010 etc)
Had a lot of fun though, and learned a lot!
2
u/Admirable-Guess5508 Sep 25 '26
Okay, yes the code is bad, but what is dad.py????
2
u/roselan Sep 25 '26
SAP: You are hired!
2
u/Zodep Sep 25 '26
Props for thinking of all those edge cases. Good job, buddy.
2
u/GolemFarmFodder Sep 25 '26
So I'm not sure I would have come up with using modulus to calculate the winner if I hadn't seen this but that's what came to mind as the easier way to figure this out
2
u/meyriley04 Sep 28 '26
I love that you and I had the same idea to make a rock paper scissors terminal game
2
u/Mountain-Ox Sep 28 '26
I wrote some similar stuff when I was learning. I've seen worse from professional devs. I don't know how you write 100 if/else conditions without stopping to question if there's a better way.
2
u/IndexIntegrity Oct 01 '26
I wrote a game a long time ago when I was 15 or so. It was a platform game and depending on your x coordinate on that level it would spawn some enemies. It was a huge collection of "if x > something then spawn enemy"Â
2
u/Edev90 Oct 01 '26
Lol - I think we all go through the "handle every possible condition with a massive if/else chain" phase of our coding careers. If it's any consolation - I've mentored many interns and entry level devs (20-24 year old age range), and I saw this coding style often even from them... so I think you were ahead of the curve at the time, đ
2
u/MMORPGnews Sep 24 '26
It's fine.Â
1
u/___Archmage___ Sep 24 '26
I was in this same boat as a self-taught 13y/o. I made something like this but for verifying sudoku
1
u/Takemitchi-kun Sep 24 '26
Glory to hash tables/dict
1
u/cyber1551 Sep 24 '26
Do I see a missing Oxford comma on line 5?
The code I can forgive (itâs better than mine tbh), but that missing comma will forever haunt my dreams.
1
u/aLostTime Sep 24 '26
Tbf apart from DRY, this seems to be quite good for a 13 year old
1
u/Ixaire Sep 24 '26
You should see my first website at 15. It wasn't nearly as clean as your code.
1
u/DT-Sodium Sep 24 '26
I did something like this at an exam and got a 9/10.
1
u/jbFanClubPresident Sep 24 '26
13 year old you was writing college level me code. Nice work.
1
u/DynamicHunter Sep 24 '26
Hey we all start somewhere. This is how a lot of AP CS high school studentâs first project looks like lol
1
u/Mjukglass47or Sep 24 '26
This code is actually totally fine.
1
u/Multidream Sep 24 '26
Its copy pasty, a good way to end up with an artifact you feel proud of even if its not that great. Perfectly fine way to get started and just have fun :)
1
u/SteroidSandwich Sep 24 '26
Looks good to me. Package and ship it!
1
u/QuietNightRadiant Sep 24 '26
I uh, I code like this
1
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo âYou liveâ Sep 25 '26
So how does that loop exit? I see after each round it picks a random choice. I'm guessing inside the loop the player is offered another choice or they can enter quit or exit?
1
u/Cloned_501 Sep 25 '26
We all started with bad code. Being bad at some is the first step at becoming kinda good at something
1
u/dragonoid296 Sep 25 '26
Nice humblebrag bro
1
u/matrix-doge Sep 25 '26
Honestly, this is fine. Pretty valid implementation given this scope. I think we've all seen production codes with a whole lot more cases
hatshard coded in worse ways.1
u/P1ckl3R1ck101 Sep 25 '26
Almost peak code. Remove the loop and recalculation of cpuinput and you have the most readable, simple code that has ever existed.
1
u/No-Point8651 Sep 25 '26
Dont you worry, the number of times I have seen 100 ifs in sequence instead of just a switch statement in production is astonishing...
Enterprise codebases are pretty much held together by hopes and dreams
1
u/AlexMelillo Sep 25 '26
You should be proud of 13 year old you
1
u/Fricho Sep 25 '26
We've all been there. I wrote similar code when I started
1
u/GreenWoodDragon Sep 25 '26
I should introduce you to some spaghetti code I was reviewing yesterday. In a production system đ
1
u/LearningProcesss Sep 25 '26
definitely better than my ultra performant 10x colleagues
1
u/stlcdr Sep 25 '26
You mean clever code. Itâs not clever, and apart from string comparisons, probably quite efficient - also teaches you how to play rock/paper/scissorsâŚ
1
u/GrumpyGlasses Sep 25 '26
Any sufficiently complex if-else statement is indistinguishable from AI. So, youâre on your way there!
1
u/ThomasTTEngine Sep 25 '26
This is how kids learn. literally looks like one of my kids assignments for school (except in their case, the CPU input was a separate function that returned a random value from an array).
1
u/Secret_Barracuda168 Sep 25 '26
I have been staring at this thing for a while, I like the code, it's better than some of what I've seen from experienced coders, and unlike some people (me) you have self declaring varibkes (can get feel for what they are based on name), so in many ways you were better then than I am today
1
u/ExistingAd2066 Sep 25 '26
Lol, my code at this age was full of GOTO +)))
1
u/JackReedTheSyndie Sep 26 '26
If you feel annoyed when doing this thatâs a good sign
1
u/bloody-albatross Sep 26 '26
When I was 13 my family didn't have a computer. So any code is infinitely better than mine at 13.
1
u/JmcmProgrammer Sep 26 '26
Gotta learn somehow. At least you got every matching branch possible and didnât leave any to chance! Now the real challenge: find the most efficient way possible in terms of raw processing speed! Or find the most aesthetically appealing code that compiles!
1
u/FreshPitch6026 Sep 26 '26
Yea that wasnt you
1
u/Ransomwave Sep 26 '26
I remember at 13 I used the default Python IDE that came with the install. It was so horrible đ
1
u/Beaver_International Sep 26 '26
Iâm about to graduate with a BS in computer science. This code is still better than mine without codexâŚ
1
u/False-Beautiful-1246 Sep 26 '26
1
u/soviel_dazu Sep 26 '26
It's not inefficient, it's optimized for using as little jump opcodes as possible for best caching behavior!
1
u/False-Beautiful-1246 Sep 26 '26
13 year old me was also inefficient. I remember a pygame game and each player had a copy of the sprites, using like 4 GB of your ram in a simple platformer.
1
u/FackThutShot Sep 26 '26
Looks Like Nemotron 3.5 550B Coded it
1
u/Spiritual-Pen-7964 Sep 26 '26
AI could produce in the same game in just 5000 LOC and 50M tokens. Bro.
1
u/HaroerHaktak Sep 26 '26
Not enough lines.
If player_input == "Rock":
if cpu_input == "rock":
output
if cput_input == "scissors":
etc etc
1
u/The-Albear Sep 26 '26
I have seen way worse code in enterprise systems.
1
u/YeeeeeBoyy Sep 26 '26
wth is dad.py đ
1
u/Loud-Scientist6915 Sep 26 '26
Was there ever a case where âplayer == falseâ
1
u/AnteaterMysterious70 Sep 26 '26
I wrote 200 lines of code for tic tac toe đđ
1
u/Ok-Prior2621 Sep 26 '26
During my school time, a long time ago, I once tried creating the game of criss-cross using PowerPoint presentations and highlighting the slides by literally creating slides for all the cases
1
u/neuronym Sep 26 '26
And a dirty screen
1
u/Different_guy09 Sep 26 '26
I guess the best way to do it would be something like:
losesTo = {
"rock": "paper",
"paper": "scissors",
"scissors": "rock"
}
if cpuinput == losesTo[playerinput]:
print("You lose!")
elif cpuinput == playerinput:
print("Tie!")
else:
print("You win!")
...or something, I dunno. At least, that's what I would've done.
1
u/ziplock9000 Sep 26 '26
You're still taking screenshots with a fucking camera tho lol
1
u/dekonta Sep 26 '26
itâs cool that you still have that code
1
u/SeaWord3693 Sep 26 '26
holy shit i made tge same program and it looked tye exact same
1
u/Wojtek1250XD Sep 26 '26
The thing that hurts the most here is not general inefficiency, but the fact that these aren't
elifs, so you have a chance of multiple outcomes happening from a single input.1
u/rolling_atackk Sep 26 '26
I'd say this is needed for any programmer
You must first start out writing garbage code, so you can much more appreciate elegant code
1
u/Several_Bite_5611 Sep 27 '26
I didn't even have a computer at 13.
1
u/CraigAT Sep 27 '26
I admire the commitment to type all that out. Especially in today's world of autocompletion, code snippets and AI.
1
u/ZestycloseEstate4056 Sep 27 '26
WHERE ARE THE ELIF LOOPS!
1
u/MisterPantsMang Sep 27 '26
You've got to start somewhere. 20 year old college me also like to write inefficient code
1
u/Novel_Plum Sep 27 '26
I remember being 13 and having that many nested for loops, that I used every variable from i to zero and had to use za, zb, ...
1
u/elloMotoz Sep 27 '26
Dude, I'm 34 and have dabbled in coding for the past few years. I went the hardware route when I was 13...wish I did some coding. Awesome you still have this code on hand.
1
u/GolfballDM Sep 27 '26
If brute force doesn't work, you're not using enough. đ
1
u/Felixgamer27 Sep 27 '26
It could be way worse, and you were 13, nothing much to expect
1
u/Silent-Image5882 Sep 28 '26
Code archeology is such a rewarding feeling. From "made this game to learn about for loops" to "memory-safe typestate wasm compiled in production"
1
u/Any-Woodpecker123 Sep 28 '26
Better than half the code I see at work. If it works it works.
1
u/levy4380 Sep 28 '26
Hey, don't be so harsh! At least you weren't trying to code a chess game.
1
u/Amazing_Peach_6690 Sep 28 '26
At least you were writing code at 13
1
u/Dee23Gaming Sep 29 '26
Honestly looks way better than many C++ programmers who've got a point to prove.
1
u/JAXxXTheRipper Sep 29 '26
And current you still doesn't know how to screenshot
1
u/thelurkmasterr Sep 30 '26
If the goal was to practice using conditions in Python code, this is probably the best implementation for that.
1
u/Kadigan_KSb Oct 10 '26
And it's STILL BETTER than PirateSoftware's. XD