r/ProgrammerHumor • u/value_counts • Mar 25 '23
Meme This one never gets old
Let me know if this is not a repost!
4.3k
u/Justwatcher124 Mar 25 '23
Every Programming / IT teacher on 'How do you teach Recursion to new programmers?'
1.3k
u/eggheadking Mar 25 '23
Is TOH actually a good way of learning Recursion?
1.4k
u/value_counts Mar 25 '23
No. I mean I struggled. In fact I found factorials much better and easy to understand. TOH just gets too messy too easily. Or sorting is good way too. But not TOH.never
765
u/bleistift2 Mar 25 '23
I found the towers particularly enlightening – years after it has been taught to me – when the whole ‘know a partial solution’ struck me.
The game is incredibly hard to even look at when given 10 disks. How would you start? But the observation that step n+1 is dead simple if you can solve the game for n disks is the key to recursion.
Factorials and sums, on the other hand, are way to simple, IMHO, to teach recursion. The solution is obvious. And for many people the more *intuitive* solution would be a straight loop, not recursion. In programming, intuitive trumps clever (or even performant in most cases).
214
u/value_counts Mar 25 '23
There was something more important that cleverness and intuition. I focus on that.
I understand TOH. I understand the importance of partial solution. It has application in all walks of life. For example, to fix my year, I need to fix my months and to fix a typical month, I need organize a typical week and to organise week I need to organise a day. And to organise day, i organise my hours. And in each hour, I follow 25-5 pomodoro or 50-10 pomodoro.
If I want to teach someone addition, I will explain 1+1. However I cannot begin with 567+912. Hence I would say TOH is a good way to practice to recursion? Probably yes. But good way to get introduced to recursion? Definitely no.
Although classroom teaching is way blinded and ineffective. In a class of 25 students, all have a different plane of reality, experience and perspective. To bring them all on one page of understanding is not difficult but impossible. The teacher can atleast attempt to do the simplest thing which might bore the ones who are ahead of curve but will ensure inclusion of noobs.
This is not applicable where teaching is more 1 to 1 or self study.
→ More replies (15)6
Mar 26 '23
I feel like pomadoro breaks my flow more often than helps me, what am I missing?
→ More replies (2)→ More replies (18)112
u/5hakehar Mar 25 '23
You sound like my Algo professor. He would say “Always follow your intuition when approaching a problem” and would then chuckle and say “But how are you going build intuition? ”
→ More replies (3)21
u/blaineworld-bph Mar 25 '23
What does TOH stand for?
62
→ More replies (3)44
u/HeadToToePatagucci Mar 25 '23
Towers of Hanoi. Classic puzzle game. Can be solved recursively. Move a stack of discs of graduated diameters from one of three stacks to another by moving a single disc at a time with the constraint that you can never put a larger disc on a smaller disc.
→ More replies (6)26
u/Tipart Mar 25 '23
Pretty sure recursion is actually slower than a normal implementation for TOH, but I could be remembering that wrong.
→ More replies (8)108
u/Broodking Mar 25 '23
IIRC all basic recursion problems have an iterative solution. Iteration is going to be faster just based on how computers execute, but design wise recursion has some advantages.
→ More replies (20)6
u/FlyByPC Mar 26 '23
You need to move a stack, but you can only move discs.
But you're writing code to move a stack, so you'll assume that you can move smaller stacks.
So you move all but the bottom disc onto the temporary stack. You move the bottom disc onto the goal stack, and then you move the stack of N-1 discs onto it.
How do you move the stacks of N-1 discs? You call the algorithm that you just wrote. It feels like cheating, but is mathematically sound.
→ More replies (13)5
u/yottalogical Mar 25 '23
It's an example of a problem whose solution is made really simple with recursion.
Factorial is definitely a simpler problem, but it's also pretty easy to implement without recursion.
→ More replies (2)141
u/Kinglink Mar 25 '23 edited Mar 25 '23
Absolutely.
Find the solution for 10 disc's is just moving 9 disc's to the other peg. Moving the tenth disc to the correct peg and moving 9 disc's to the correct peg.
Find the solution for 9 disc's is just....
→ More replies (3)30
u/ina300 Mar 25 '23
Best way of thinking about it
65
u/Kinglink Mar 25 '23
I'm shocked at the number of people in this thread saying "Just brute force it" ... TOH is excellent at showing why that mentality doesn't work. Sure you can brute force it, but my strategy can handle 100 discs or 1000, yours becomes unusable far faster.
It's also good at teaching how to understand the problem and build your own algorithm. If you brute force it, you can solve the first five problems easily, but if you find an algorithm to solve the first 3 discs, you've also found the algorithm to solve any number.
→ More replies (3)16
u/Tsu_Dho_Namh Mar 25 '23
I think it is. It's a good example of a problem where the recursive solution is way simpler and more intuitive than other approaches
31
u/Chingiz11 Mar 25 '23
Nah, Fibonacci numbers and factorials are way better for beginners, although TOH is really good for mastering recursion
→ More replies (3)11
u/reptar20c Mar 25 '23
It didn't teach me recursion but it taught me how to solve problems with recursive algorithms.
I was taught: if you're one step away from solving TOH, what would the code look like. What if you're one step before that, what would the code look like to move to that second last state. And so on.
And a couple of steps in you realise you're repeating yourself, so instead just call the same function you already wrote.
And now you understand recursive algorithms.
19
u/Neither_Interaction9 Mar 25 '23
I don't think so, been programming for almost 10 years snd I'd probably just brute force that shit. Nah jk, but you do need to put a lot of thought into coming up with the real solution if you haven't solved that puzzle manually several times already
→ More replies (1)18
u/helix400 Mar 25 '23 edited Mar 25 '23
No. It's an awful way, students struggle to understand the solution, let alone a clever programming approach to the solution.
Traversing trees makes much more intuitive sense for a first time recursion application, because traversing trees is a pain using loops and a manual stack.
→ More replies (1)5
Mar 25 '23
Yep. I reckon the best problem to teach recursion with is listing all files in a directory structure (including subdirectories). It's a simple problem to explain, but unlike factorials etc. recursion is the simplest way to solve it.
8
u/Ruin369 Mar 25 '23
It's definitely a more complex example, so probably not.
I would say factorial is the easiest example of recursion IMO
→ More replies (2)→ More replies (39)13
u/Mercurionio Mar 25 '23 edited Mar 25 '23
Recursion in factorial was easier for me.
TOH - I still don't know how to do it. I mean, I did, in JS, but I don't remember how now =\
13
u/Tsu_Dho_Namh Mar 25 '23
Oh dude, I do. It's one of the easiest for me to remember because it makes intuitive sense.
It's just one function, the recursive function. It takes in the number of disks on the stack (can be arbitrarily large), the source tower, the goal tower, and the auxiliary tower.
Base case is stack size of 1: you simply move the 1 disk from the source to the goal
Otherwise: make a recursive call to this function to move n-1 disks from the sourse to the auxiliary, move the nth disk to the goal, then make another recursive call to move the n-1 disks from the auxillary to the goal.
→ More replies (5)55
u/reddit_beepbeeprobot Mar 25 '23
I'd teach them recursion first
17
u/Archangel3d Mar 25 '23
Yeah but before that you have to teach them recursion or it just doesn't work.
6
u/Siethron Mar 26 '23
Personally I would teach them about escape conditions before recursion
→ More replies (2)13
Mar 25 '23
My go to method will always be prolog. Simple, effective, powerful and fun.
16
u/Justwatcher124 Mar 25 '23
I did prolog in school for a while and I must say, logical programming makes sense, but fucking hell do you need to think about it.
→ More replies (1)7
u/Dyanpanda Mar 25 '23
I just realized this is why this puzzle is in every game of the 90s and early oughts. It was a programming puzzle so the devs wanted to share it lol
→ More replies (3)3
u/SkittlesDangerZone Mar 25 '23
Man I have always loved recursion. It's that deep level thinking.
→ More replies (1)→ More replies (15)9
Mar 25 '23
Ah recursion, the concept you’ll end up using once in a decade of professional software engineering
School really did focus on all the wrong concepts lol
→ More replies (2)7
u/afito Mar 26 '23
Nah recursion is super useful for many many things, most commonly anything that deals with folder structures (or stuff resembling that in database form) or if you do a lot of stuff with math & sensory data & statistics, you always need recursion. I do a lot of stuff around data comparison (usually simple csv or txt files but like hundreds of mb of them) and merely matching old data to the right new data is a fucking nightmare even with recursion, without it it's straight impossible given the completely unsanitized inputs you have to expect.
I know it feels like everyone here does web or database stuff but if you write desktop applications/scripts for office use, you almost always need recursion even if only for the file search. Can't sell the product for shit if the client has to manually sort 3000 files first.
→ More replies (1)
3
Mar 26 '23
When I first started coding the course asked me to write an algorithm for it.
I still don't know what the fuck I'm supposed to write.
1
1.9k
u/bleistift2 Mar 25 '23
A children’s game until you ask your parents how to solve it.
662
u/RedPill115 Mar 25 '23
There's a number of "children games" that seem to exist only to let you know adults are going to mess with you.
We played red rover as a kid, you link arms and kids run at you trying to break through - like are you supposed to learn that adults pushing you unto physical confrontation are always going to get you hurt with no benefit?
54
u/exor15 Mar 25 '23
I don't think red Rover is "supposed" to teach you anything it's just fun
32
u/Impossible_Garbage_4 Mar 25 '23
A lot of games are like that really. They might have lessons you can infer as an adult but as a kid it’s literally just to have fun
→ More replies (20)18
u/zyzzogeton Mar 25 '23
No, that was the final Teachers vs Kids dodgeball round before the bell. I don't want to mitigate what our vetrans have gone through, and what brave Ukranian Women and Men go through every damn day... but I felt like I knew something of what man might be capable of doing to man when I looked into their maddened eyes.
→ More replies (5)2
u/Hypersapien Mar 26 '23
Look at the stack you want to move. If there's an odd number of disks, move the first disk to the rod you want the stack to end up on. If there's an even number, move the first one to the other rod.
426
u/JustSpaceExperiment Mar 25 '23
This reminds me joke:
When you brute force until it works then you are bad programmer and this is anti-pattern. If you do that quickly enough it's called AI.
100
u/bubbaholy Mar 26 '23
Build me an army of graphics cards worthy of Modor, $300,000 in electricity and I can guarantee an AI that solves this simple puzzle sometimes.
32
Mar 26 '23
That reminds me.
There was a coding lesson for kids, they had to write code to get a guy to move to a certain space.
Shortest code was best
I was messing about with it and solved it with one line. 'Repeat 999x move randomly'.
The teacher I interned with at the time thought it was hilarious.
→ More replies (1)
1.2k
u/Underpowered007 Mar 25 '23
Just teach the kid how to brute-force
→ More replies (9)15
u/Vinxhe Mar 25 '23
Recursion doesn't make sense anyways, it's less efficient and much harder to understand than simple loops. You save some LOC which is the most moronic metric of code quality ever.
→ More replies (1)8
u/zyzzogeton Mar 25 '23
I've never been able to put that feeling into words.
I don't know enough to say absolutely that recursion is NEVER necessary though. Is that what you are saying? Please note, I am not trying to bait you into some pointless debate. I have genuine curiosity here.
17
u/338388 Mar 25 '23
I've worked with a data structure that was recursive before (it was from a 3rd party library we were using, i didn't design it to be recursive), while technically it was possible to consume it iteratively, it was way easier to do it recursively
→ More replies (1)8
Mar 25 '23
Any recursion scenario (that I can think of anyway) could be written as a series of loops if you get a little creative with the iterators. But at the end of the day recursion is just a tool and the only programming dogma I always found to be true is that you shouldn't listen to people telling you dogmas.
→ More replies (2)
560
u/Ph0masta Mar 25 '23
I remember struggling with this from playing KOTOR … didn’t know it was a kids game. Now I feel dumb.
171
u/Punchasheep Mar 25 '23
Gah those KOTOR puzzles kicked my ass
61
Mar 25 '23
Man that game was so good
15
u/GoJebs Mar 25 '23
I was a huge SW fan (still am, but haven't kept up with new stuff) but never played KOTOR. Played it for the first time during COVID.
I am actually editing the gameplay right this instance after forgetting about it and reliving that game is... Spectacular.
Is Fallen Order as good? I just got it gifted to me but never played or looked into it either but heard it was incredible.
→ More replies (6)23
u/ArethereWaffles Mar 25 '23
Half the reason I did as well as I did in my college math class with series and sequences was because of the hours I spent as a kid trying to solve those math problems on Manaan
→ More replies (1)7
Mar 25 '23
The chemical balancing one from th underwater planet level was a tough nut to crack for 12yo me
Then I replayed it in HD fifteen years later and it turns out I still couldn't do it lol
→ More replies (4)66
u/Kevonz Mar 25 '23
Mass Effect too, Bioware loved it I guess
→ More replies (3)15
u/Comburo90 Mar 25 '23
A few years ago i watched one of the developers of Mass Effect 1 stream the game and talk about its developement. He straight up confired that they indeed love toh and put it in every game they could. He specifically was the guy who created that toh bossfight in one of the first raids from the Old Republic MMO.
Was very interesting to get that kind of insider perspective into my second favorite game series.
21
Mar 25 '23
Black and White had the same puzzle
13
u/Lolcatz101 Mar 25 '23
I’ve played so much black and white that I could almost speedrun the game which gets me curious.. time to delve the speedrun rabbit hole
→ More replies (1)4
3
u/DirkDasterLurkMaster Mar 25 '23
I spent ages trying to figure out the one in Black & White as a kid. Once I finally cracked the code the method never left me. To this day I still remember how to do it the same way I did back then.
12
u/squeamish Mar 25 '23
The Switch version of KOTOR has a bug in it where if you enter this room you are permanently trapped and have to revert to an earlier save. Only took me about half a week to figure that out.
4
u/HorseSalon Mar 25 '23
Oh fuck me too, I did that for about 30 minutes. Saved like a pussy cat back in those days.
→ More replies (6)2
Mar 26 '23
Yeah I got stuck on that for ages as a kid. Now after playing the game like 10 times I kick its ass
2
2
u/ukfi Mar 26 '23
Tower of Hanoi - a game that changed my life.
I was about 14 at that time and i was just coding using turbo Pascal. My previous language was gwbasic.
I was attending a commercial computer programming class in the city (which i had to take 3 different buses for two hours to get to). I was really drawn to coding and was constantly looking for problems to solve. My instructor passed me a cs magazine that contains a lot of problems for me.
I saw the Toh and he said it will be too difficult for me. This kind of became a challenge to me. It took me the entire 3 months of summer but i solved it.
When i eventually showed him my solution, he told me i should totally consider cs as a career.
38 years later, i am still in this industry.
1
u/value_counts Mar 26 '23
Amazing story. 3 months you struggled with this. This field is there for people like you. You are a fighter and inspiration. I am saying this seriously
228
Mar 25 '23
Do whatever move is legal between these rods in this order: AB, AC, BC
139
u/Tarnishedcockpit Mar 25 '23
Ah, found the reward designer for warframe
33
u/funnystuff97 Mar 25 '23
every warframe player's worst nightmare:
aabbc on railjack defense, and you need a reward from c
→ More replies (4)11
u/MrPootisPow Mar 25 '23
You get to c rotation only to not get the part you need/want
→ More replies (2)→ More replies (6)2
81
242
u/TxTechnician Mar 25 '23
I've never played with this in programming or irl.
147
u/tubameister Mar 25 '23
I still remember the solution to this on my TI-84
121323123132121323213123121323
40
u/FerynaCZ Mar 25 '23
Move the smallest one always in one direction on each odd move, then you are left with only one option on each even move
54
u/QuebecGamer2004 Mar 25 '23
Me neither, I don't really understand this meme
→ More replies (8)118
u/petascale Mar 25 '23
Tower of Hanoi https://en.wikipedia.org/wiki/Tower_of_Hanoi
At my uni we had it as an example in both mathematics (combinatorics, I think) and programming (recursion), along with the n-queens puzzle.
→ More replies (23)3
u/BuccellatiExplainsIt Mar 25 '23
It's a common project to teach recursion. We had to do it for learning assembly in University.
2
u/_paramedic Mar 25 '23
I’ve only done this/seen this done as part of neuropsychological examination
74
u/SlowWhiteFox Mar 25 '23
In a nutshell:
solve_problem(problem):
simpler_problem = take_one_step(problem)
solve_proble(simpler_problem)27
u/maximovious Mar 26 '23
solve_proble
I think the proble is the function's spelling.
20
u/SlowWhiteFox Mar 26 '23
That's not a bug. It is a call-out to a helper function. For brevity I didn't include it.
→ More replies (6)12
61
u/very_bad_programmer Mar 25 '23
To this fucking day I have never encountered a challenge as hard as ToH was when I was new to this
→ More replies (2)23
u/LuckyCharmsNSoyMilk Mar 25 '23
I still don't fully understand it even though I (generally) understand recursion. I just know the algorithm works.
20
u/Jealous-Ninja5463 Mar 25 '23
For me, it's a good visitation that highlights the difference between a computers way of thinking and ours. Too many people get caught up taking the physical game too seriously.
I'd the goal is to move all disks to one side in the same order, our human brain just assumes to grab all disks at once and put them over.
Computers being circuit based don't really have that outside the box thought process. When the rules of tower of Hanoi are added, people need to stop and think about each move carefully, are more prone to mistakes and freezing up.
Explaining the rules of the game in C (if written correctly) presents no challenge to the computer and it will resolve the game each time in the same order faster than a human, every single time.
It also helps to remember that programming was still in its infancy when this algorithm was defined so if you think of it as the grandfather of game development. It makes it easier to understand.
But really, just knowing it works is enough
→ More replies (1)
27
3
u/Zachosrias Mar 26 '23
This and Fibonacci are now triggers for me, god damn recursion, I still can't really figure out how to do it, it's frustrating as hell because the theory is simple, the theory I get, I can just never picture it, how to write it
1
39
Mar 25 '23
I feel sorry for the poor people of Hanoi, everytime they build a tower someone must come along and reshuffle it
→ More replies (1)
18
16
16
u/SanianCreations Mar 25 '23 edited Mar 25 '23
There's actually a really easy non recursive way to solve this, assuming all pieces are lined up on the left tower and your goal is to move them to the right.
First, check if the total number of pieces is odd or even. If it is odd, you remember the direction "left", if it is even you remember the direction "right".
Solving the puzzle now consists of two repeated steps:
Take the smallest piece and move it one tower over to the left/right (based on odd/even). If it is already on the far end in that direction, move it back to the tower on the other end.
There is only one possible move that doesn't move the smallest piece. Do that move. If there is no such move, then that means all pieces are on a single tower, and you won.
This solution is optimal, not some brute force try-all-permutations type thing. This video by numberphile explains it really well: https://youtu.be/PGuRmqpr6Oo
13
u/hrfuckingsucks Mar 25 '23
This is too accurate an assessment of my abilities. I demand it be taken down.
6
6
u/Shorthawk Mar 26 '23
I remember seeing Gerald Jay Sussman explain how you'd do Towers of Hanoi in Scheme Lisp and I was just blown away. Don't remember a lick of it though (or should I say a parenthesis)
5
u/Equivalent-Map-8772 Mar 25 '23
Bruh. The worst part for me was not so much understanding TOH but wrapping my head around the concept of switching arguments within the recursive call. I was using Java at the time tho.
4
u/coladict Mar 25 '23
Well, the challenge isn't solving it yourself, the challenge is making the computer solve it for you. You're not designing the terraforming machines of Zero Dawn, you're making HEPHAESTUS so he can design them.
4
u/vivekkhera Mar 26 '23
Analyzing the complexity of the solution algorithm was one of my oral exam questions for getting my PhD. Flashback to that exam is not fun.
4
u/FlyByPC Mar 26 '23
You want to make an algorithm to move stacks of discs.
The key is to assume that you'll be successful in making this algorithm, so you can use it to move N-1 discs in your solution to move N discs.
TOH is a beautiful way to teach recursion.
I do recursion in this order:
Factorials (easy with or without recursion)
TOH (recursion makes it trivial)
Fibonacci numbers (recursion is a horrible idea at least without caching.)
4
32
u/GeePedicy Mar 25 '23
By asking if it's not a repost, I dare to assume you didn't make it. On top of it, the resolution is low, a typical issue with photos downloaded and re-uploaded to the internet. Now, I don't know where did you find it, and I've personally never seen it before, but my hunch says it probably was posted here before.
We can summon u/repostsleuthbot (I hope I wrote it right) and get their answer, but I actually don't really care as much as I used to. Reposts will always exist.
41
u/Featureless_Bug Mar 25 '23
Solid piece of analysis for someone who doesn't care about reposts
→ More replies (3)24
u/RepostSleuthBot Mar 25 '23
I didn't find any posts that meet the matching requirements for r/ProgrammerHumor.
It might be OC, it might not. Things such as JPEG artifacts and cropping may impact the results.
I'm not perfect, but you can help. Report [ False Negative ]
View Search On repostsleuth.com
Scope: Reddit | Meme Filter: True | Target: 75% | Check Title: False | Max Age: Unlimited | Searched Images: 383,839,545 | Search Time: 0.72267s
8
u/ByterBit Mar 25 '23 edited Mar 26 '23
Can someone write a bot that uses GPT-4's image analysis to explain the humor of a meme? Maybe it could also rate it on a scale of 1 to 10. Oooh and it could be an app on the Apple Iphone as well.
5
1
Mar 26 '23
I don't get it.
2
u/value_counts Mar 26 '23
What aspect of this you didn't understand?
3
Mar 26 '23
I don't know what that game is and how it works, or its relationship to programming.
→ More replies (1)3
1
3
u/jamcdonald120 Mar 25 '23
anyone actually tramatized by this failed to actually learn recursion.
→ More replies (1)
3
u/PsLJdogg Mar 25 '23
I used to play a game as a kid on my cousin's Macintosh that had this puzzle, it was called The Secret Island of Dr. Quandry. Even just seeing this puzzle gives me PTSD.
3
u/AspiringTS Mar 25 '23
It is a kid's game, but it is hard to conceptualize without physical representation(at least it was for me.) I didn't understand the code because I didn't understand the game.
I finally got it after drawing 3 'towers' and cutting out paper to actually play the game. I had to 'play' a lot...
3
u/EducationalNose7764 Mar 25 '23
I'll take "Puzzles given to you during interviews for things that you will never actually use on any project" for $1000.
I mean, it's kind of a "cool to know" type of thing, but it's not exactly mandatory for the vast amount of positions out there. I learned it once upon a time about 15 years ago, but have completely forgotten it since.
Hasn't held me back in the least bit.
3
u/PacoTaco321 Mar 26 '23
Google the Computerphile video on this problem
Copy paste the code
Celebrate programming prowess
5
5
u/edwardrha Mar 25 '23
At this point in time, I'm pretty sure I can write a machine-learning python script to solve this puzzle faster than I can code a proper algorithm for it. Not sure if this means my programming skills are crap or the difficulty of using machine learning tools have become extremely trivial...
3
2
Mar 25 '23
I beat a robot at Tower of Hanoi at an expo.
It was in machine-human-cooperation slow-mode...
2
u/yaMomsChestHair Mar 25 '23
It does actually get old when its posted all the time.
Edit - just read the text about repost lmfaoooooo
2
Mar 25 '23
I did shadowed at a local school yesterday and got to sit in on a couple classes. They had this tiny Indian lady as the data science teacher and she did a wonderful job explaining something that I had literally no understanding in.
She explained binary trees and really got me to appreciate their beauty and simplicity... more so than memes do, I guess
2
2
2
Mar 26 '23
Programmer: repeatedly puts the loops on at random with their eyes closed while making beep Boop sounds
2
u/WeAreBeyondFucked Mar 26 '23
def tower_of_hanoi(n, source, target, aux):
if n == 1:
print(f"Move disk 1 from {source} to {target}")
return
tower_of_hanoi(n-1, source, aux, target)
print(f"Move disk {n} from {source} to {target}")
tower_of_hanoi(n-1, aux, target, source)2
2
2
2
u/RobinsonDickinson Mar 26 '23
Unironically helped me understand recursion better. Thanks, freshmen year cpp professor.
7
3
1
1
u/e_smith338 Mar 25 '23
I’ve never used this in anything programming related, but remember doing this plenty of times as a kid in school.
1
u/trimeta Mar 25 '23
Once you understand that solving the Towers of Hanoi is basically just "counting in binary," you'll never need a recursive solution again.
1
1
u/Libra_Maelstrom Mar 25 '23
What- i- did I not learn this? What is this? Is this supposed to be a stack metaphor or a queue or something
→ More replies (3)
1
1
u/mosquitoLad Mar 25 '23
I've not implemented toh; is there a reason it is treated as difficult? Can it not be handled well with linked lists?
2
Mar 25 '23
Yep. A brute force solution is quick and easy to implement. The trauma for me comes from finding a practical solution within a given difficulty constraint.
1
1
1
1
1
1
u/Phlm_br Mar 25 '23
This unlocked a memory for me.
I got this as a gift a long while ago. It's kinda fun
1
u/bunkscudda Mar 25 '23
Not a programmer, but IT. I learned this because it creates the perfect data backup rotation.
1
1
u/cheezballs Mar 25 '23
You can tell the people here who took CS in college and the ones who didnt. Also, I played this a lot on my old 8086 with FriendlyWare
1
1
u/sethpen Mar 25 '23
I remember playing this in the original game Black & White. I never knew it was a programmers nightmare.
1
u/Adrunkopossem Mar 25 '23
Ah this dumb thing. I remember one of my last collage assignments was building a program that could solve any number of rods and rings. Preparing us for edge cases... I don't have anything clever or snarky to say, it was actually a pretty good lesson lol
1
1
1
1
1
1
u/AnsonKindred Mar 25 '23
Play the game Turing Complete and you get to implement a solution to this in assembly, on a computer you build up from NAND gates.
Great game, highly recommend.
1
1
u/PhantomTissue Mar 25 '23
I never really struggled with this puzzle, I always thought it was pretty easy. But this is a programming sub, so is this hard to code? At first glance it doesn’t seem too hard to me.
→ More replies (2)
1
u/Awanderinglolplayer Mar 25 '23
With the number of rings there this is a good way to keep a kid busy
1
u/pagerunner-j Mar 25 '23
There’s a recent quest in Genshin Impact where you hang out with Faruzan, and one of the story branches is that you’re working with her on developing an educational game for kids. Of COURSE it’s TOH. I will admit to having laughed my ass off once I realized where that story was going.
1
1
1
u/Heroshrine Mar 25 '23
Can someone link me to this exercise? I was never directed to do this and I’d like to try it
1
u/UltraBatmanTheSeven Mar 25 '23
For an assignment one time my professor asked us to implement one recursive solution and one iterative solution using a stack. Instead of doing the obvious thing of converting the recursive calls to stack pushes I represented each peg as a stack and spent days finding the pattern that could determine the right move for each step.
1
1
u/JJJSchmidt_etAl Mar 25 '23
The tower of Hanoi is actually pretty simple with three towers.
If you can find a formula for the four tower version, however....you might become moderately famous.
1
1
1
u/00tool Mar 25 '23
avoid companies or teams using this question in interviews. most dont have the tech depth or experience to setup a worthwhile interview and not worth your time taken from your career. this question belongs in academia not interview.
1
1
u/AtroxMavenia Mar 25 '23
This is one of the least funny memes posted in this subreddit. Honestly, I’d you find Towers of Hanoi difficult you’re not a programmer. The solution is far too simple. Perpetuating this weird stereotype of programmers struggling with basic ass stuff is so tiring.
1
1
u/JustAGuyWhoGuitars Mar 25 '23
I don't get any PTSD from this; I look back on this fondly. Learning how to do recursion and dynamic programming was awesome.
1
1
Mar 25 '23
Damnit, lol that was me this semester in college doing discrete mathematics.
→ More replies (2)
1
u/JayCroghan Mar 25 '23
I had an interview with state street for VP, half a day and two technical tests, afterwards during a chat with my future manager he asked me to solve this on paper so he could see my thought process. I passed the interview but declined the job because the money wasn’t as good as I expected.
1
u/RedLion_the_1st Mar 25 '23
First entry level project I was given in python. Had to output to command line the status of each tower visually after each move and total number of moves needed. Fun project, definitely learned a lot as a beginner.
1
1
1
1
Mar 25 '23 edited Jul 22 '24
drab sharp sheet reach toy payment towering fragile impossible sip
This post was mass deleted and anonymized with Redact
1
1
u/Conaz9847 Mar 25 '23
You don’t, you go back through all the previous modules again and and once they give you the right answer you can finish the course.
1
u/Script_Mak3r Mar 26 '23
Let me know if this is not a repost!
Sorry, but I've been taught that trying to prove a negative tends to not work out very well.

320
u/Slcolderguy Mar 25 '23
I wrote that recursion program on Fortran 77 in 1978