TheaterFire

This one never gets old

Posted by value_counts@reddit | ProgrammerHumor | View on Reddit | 596 comments

This one never gets old
Let me know if this is not a repost!

Reply to Post

596 Comments

Ph0masta@reddit

I remember struggling with this from playing KOTOR … didn’t know it was a kids game. Now I feel dumb.
View on Reddit #154881

Punchasheep@reddit

Gah those KOTOR puzzles kicked my ass
View on Reddit #155444

cr125rider@reddit

Man that game was so good
View on Reddit #157615

GoJebs@reddit

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.
View on Reddit #162385

WhiteChocolatExpress@reddit

Fallen Order is a great game, but much more straighforward story-wise. Very fun, cinematic Dark Souls-like, but the main character is who he is. Helps that I think the game's story is pretty good, though
View on Reddit #162886

GoJebs@reddit

Ah, never played Dark Souls either. Sounds like I will try it out though! Sucks there aren't choices
View on Reddit #163887

mickey_patches@reddit

Try KOTOR 2 with the restored content mod if you haven't yet. Choices like Kotor but different
View on Reddit #274532

GoJebs@reddit

Stream made me play both, I will say I didn't enjoy it nearly as much. Didn't connect with the characters on the same level and the narrative was way more confusing/shrouded in mystery till the very end. Though, it could have been left over feelings after that freaking first level in the miner facility. That took FOREVER and was annoying. Heard there were mods just to skip that part and if I ever played it again that would be my first download. After KOTOR 1/2 stream told me that Mass Effect was a good go to, and I have been loving that since. On #3 right now.
View on Reddit #274862

WhiteChocolatExpress@reddit

It's actually a great intro to Souls-like games, since the difficulty options are pretty good & can be changed mid-game. That lets you start out reasonable & ramp up to more "Souls-ish" diificulty, since it actually affects things like parry timing & enemy agression
View on Reddit #166525

ingannilo@reddit

Fallen Order is excellent, but it’s not an RPG. It’s a souls-style game focused on melee combat, exploration, and puzzles. Sequel drops soon too.
View on Reddit #171720

MikoMiky@reddit

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
View on Reddit #160354

Punchasheep@reddit

My experience exactly. I think I actually got dumber over the years....
View on Reddit #166042

kotorfan327@reddit

I couldn't figure it out as a kid either and I had to look it up. As an adult, I found the solution watching Die Hard with a Vengeance. The scene with the fountain, bomb, and water jugs is the exact same puzzle. Same values and everything.
View on Reddit #164131

Poison_Anal_Gas@reddit

Hahaha brother!! That movie is exactly why I knew exactly what to do with this puzzle. Made me chuckle for sure!
View on Reddit #165220

Taldius175@reddit

LMAO I want to go back and play it now.
View on Reddit #162845

OrangesMid@reddit

I can remember having to help my older brother with them when we were kids
View on Reddit #158750

ArethereWaffles@reddit

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
View on Reddit #158236

Kevonz@reddit

Mass Effect too, Bioware loved it I guess
View on Reddit #157720

DaniSpar@reddit

I recently replayed ME1 and dreaded this part. It was literally the only part of Noveria I remembered so that says something about the impact it left on younger me lmao.
View on Reddit #173032

Kevonz@reddit

the first time I played it it seemed impossible, after that it was actually way too easy. that's just my experience though lol
View on Reddit #173277

MaskedImposter@reddit

It shows up in Dragon Age as well. I wouldn't be surprised if it's in all of their games, or at least once per series.
View on Reddit #165044

wurm2@reddit

also Jade Empire and the Descent dlc for DA:Inquisitoin.
View on Reddit #161435

Comburo90@reddit

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.
View on Reddit #159270

chazingerZ@reddit

They even joke about it in the citadel dlc for 3 if Shepard interacts with the arcade machines
View on Reddit #158749

SkyIcewind@reddit

Same in Mass Effect. Yeah I know it's a "kids game" but like, what are the goddamn rules? Like they just throw it at you in Mass Effect and like, I've never seen it before, what is this, the blocks just refuse to move sometimes and I'm like 15 and have no idea what's going on.
View on Reddit #165589

JackJackensworth@reddit

Black and White had the same puzzle
View on Reddit #156282

Lolcatz101@reddit

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
View on Reddit #157949

umbrellacorgi@reddit

Do it!
View on Reddit #165194

DirkDasterLurkMaster@reddit

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.
View on Reddit #161020

MrPootisPow@reddit

Yeah the temple on land 2
View on Reddit #159595

TripleEhBeef@reddit

Just switch to T3-M4 and security spike it.
View on Reddit #159566

TheEnquirer1138@reddit

I thought you were forced to go it alone in that section since it was part of your character's trial.
View on Reddit #160763

crazed3raser@reddit

Yep, its in Korriban, during the sith academy graduation trial. You are forced to solo it, and on top of this puzzle it had the two Terantatek in the same room you have to fight at the same time. Alone. That could be brutal depending in how you built your character.
View on Reddit #164883

TheEnquirer1138@reddit

Last playthrough I did a dual pistol build. That was by far the hardest fight in the game for me. Malak was significantly easier.
View on Reddit #164957

crazed3raser@reddit

Ah nice, havent played in a few years but I also did pistols only as my latest playthrough. Yeah that fight was rough.
View on Reddit #164977

crazed3raser@reddit

Yeah I got stuck on that for ages as a kid. Now after playing the game like 10 times I kick its ass
View on Reddit #164849

squeamish@reddit

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.
View on Reddit #159205

HorseSalon@reddit

Oh fuck me too, I did that for about 30 minutes. Saved like a pussy cat back in those days.
View on Reddit #159339

Powerful-Brother-791@reddit

The Switch version of that puzzle is bugged and unsolvable so the game just softlocks you there.
View on Reddit #158849

Hikage390@reddit

Dont worry, i also knew this as a kids game until i saw the correct rules (only moving one disk, not allowed putting a big disk over a small one, move the tower from one stick to other in less steps possible) and with this level of using 10 disks the "best solution" is in 1023 steps, i would say "the kids game" only applies to 4 or max 5 disks until the kid will say fuck it and stacking not following the rules xd
View on Reddit #157811

Justwatcher124@reddit

Every Programming / IT teacher on 'How do you teach Recursion to new programmers?'
View on Reddit #153716

eggheadking@reddit

Is TOH actually a good way of learning Recursion?
View on Reddit #154226

value_counts@reddit (OP)

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
View on Reddit #154541

bleistift2@reddit

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).
View on Reddit #155270

SuitableDragonfly@reddit

For teaching recursion, it's probably better to teach a non-tail-recursive problem that can't be solved with a loop, to show that it's actually necessary sometimes, like merge sort for example, or tree traversals. Both of those are also easier than Towers of Hanoi.
View on Reddit #166612

sanjuro89@reddit

Speaking as someone saddled with the responsibility to teach recursion, I do both. We'll start with simple tail-recursive problems like factorial and Fibonacci numbers, do some classic CS problems that can be solved iteratively (but where it's a pain to do so) like Towers of Hanoi and Eight Queens, cover the recursive versions of sorting algorithms like merge sort and quicksort, and eventually get to tree traversals.
View on Reddit #174385

SuitableDragonfly@reddit

Huh, what is the recursive solution to eight queens? I came up with my own solution for it when I was like seven and playing The Seventh Guest, and it definitely wasn't recursive (or particularly clever).
View on Reddit #183069

sanjuro89@reddit

It's a backtracking algorithm in which you start at one edge of the board (for example, column 0) and try to place a queen in each successive column. The recursive function checks each row of a given column looking for a safe spot to place the queen. If it finds one, then it performs a recursive call with the next column and returns the result. If not, it returns false and you end up backtracking one or more columns and trying again. If you reach column 8, that's your successful base case and you can return true because you've found a solution. Depending on where you print the chessboard, you can print all 92 distinct solutions or just the first solution you find. GeeksforGeeks has pseudocode and code for the algorithm that will probably make it a lot clearer than the paragraph I wrote above. [Eight Queens Puzzle](https://www.geeksforgeeks.org/8-queen-problem/) Of course, you can easily alter this to start at row 0 and move down the board instead. Sometimes I'll make my students print only the 12 fundamental solutions, which requires them to rotate and mirror the board.
View on Reddit #188873

SuitableDragonfly@reddit

Well, that's exactly how I did it, but that always seemed like an iterative problem to me.
View on Reddit #188945

value_counts@reddit (OP)

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.
View on Reddit #155979

throw3142@reddit

TOH makes sense as an introduction to recursion *if you are already familiar with the concept of mathematical induction*. Personally I learned about induction in math first, using it to prove things like the sum of n numbers is n(n+1)/2 and there are infinite prime numbers. Going from this to TOH is a manageable step. But if I had not been exposed to this concept before, I agree that it would be very confusing and not a great introduction.
View on Reddit #161626

ThatDollfin@reddit

Well huh, would you look at that. An actual application for that thing I'm learning in math class right now. Thank you.
View on Reddit #164175

throw3142@reddit

Oh yeah, math is extremely applicable to CS. From algebra and basic proof techniques (which form the basis for algorithms) to limits and calculus (used to analyze and optimize algorithms), linear algebra (used extensively in ML, especially modern neural networks), and even geometry (used for graphics computing)!
View on Reddit #164860

SoulSkrix@reddit

CS is Maths, it’s computing. It feels like the difference between “medical science” and “forensic science”. It is just the application of the former. I’m just being pedantic of course, Mr Turing was a great mathematician who created the branch we know as CS.
View on Reddit #170493

throw3142@reddit

Nah you're right, I don't think you're being pedantic. CS is indeed a field of applied math. I think where it gets tricky is the difference between CS and programming. CS as in the study of computing is extremely mathematical. Programming as in the art of writing understandable and extensible code is not necessarily mathematical (how much math is really needed to write a React web app ...); however, I think that mathematical thinking can always help even with this kind of task.
View on Reddit #177911

JohnsonJohnilyJohn@reddit

How do you prove there are infinite prime numbers with induction? I have only seen the simple proof by contradiction: if there are finite amount of prime numbers multiply them all together, add 1 and you have a new prime number
View on Reddit #168097

throw3142@reddit

That argument uses both induction and contradiction. The first part is a proof by induction of the statement "Given a finite list of numbers, there exists a number relatively prime to all those numbers". This part of the proof works fine as is. The next part of the proof uses that part to argue that there must be an infinite number of primes (if there was a finite number, use the above procedure to construct a number relatively prime to all of them; by FTA, it must have a prime factorization, and by construction, none of the primes in the list can be its factors, so there must be another prime factor outside the list). Specifically, the first half of the proof is very similar to a recursive procedure because it uses an existing solution to construct another solution. It doesn't try to give a formula for all prime numbers or anything like that. Instead, it assumes that we already know a bunch of prime numbers and uses them to construct another one.
View on Reddit #168225

JohnsonJohnilyJohn@reddit

While the first part is similar to induction you're not really doing any induction there. With that procedure as induction step you could prove that there are infinite lists of numbers without any common factors. You could probably use this to prove infinite prime numbers but using proof by contradiction not based on whole induction but the argument from a single step is way easier
View on Reddit #168329

throw3142@reddit

I don't understand what you mean by "proof by contradiction not based on whole induction but the argument from a single step". Here is my understanding of the proof, written out in a more rigorous way: 1. The set {2} contains a single prime number. 2. Given a list of n numbers, we can find a number that's relatively prime to those n numbers by multiplying them all and adding 1. Note that this new number may not be prime itself: for example, 2\*3\*5\*7\*11\*13=30,031=59\*509 is not prime, but it is relatively prime to 2, 3, 5, 7, 11, and 13. Also, there is no requirement for the numbers in the list to be prime either: for example, 4\*5\*6+1=121 is relatively prime to 4, 5, and 6 by the same argument (even though 4 and 6 are not prime). 3. We assume the opposite of the premise (i.e., there exists a finite list containing all prime numbers). 4. We apply the construction in part 1 to this finite list, in order to find a number that's relatively prime to all of those numbers. Since this number has no prime factors in common with the prime list, and it's also not 1 (trivially), one of the prime factors of the new number must not be in the list. Thus, we have constructed a new prime which we can add to our list. 5. Repeatedly apply step 4 over and over; whenever you have a finite list of primes, you can always find a new prime that isn't in the list and then add it to the list, so the total number of primes cannot be finite. As I understand it, step 1 is the base case and step 4 is the inductive step. The proof only works due to this inductive structure. First, you prove that there is a list of 1 prime, which implies the existence of a list of 2 primes, which implies the existence of a list of 3 primes, etc. Is there any way to do the proof this way (multiplying everything and adding 1) without induction?
View on Reddit #168608

JohnsonJohnilyJohn@reddit

Oh now I get what you mean. Basically you don't need step 5. Proof by contradiction ends with step 4. If we assume that there are finitely many prime numbers, we can list them ALL and then apply the procedure, and get a new number that is both prime, and isn't any of the ALL prime numbers, which is already a contradiction
View on Reddit #168720

throw3142@reddit

Ok that makes sense. I guess I just learned it differently. But I see why the induction isn't necessary.
View on Reddit #168956

morpheousmarty@reddit

I feel like pomadoro breaks my flow more often than helps me, what am I missing?
View on Reddit #163062

value_counts@reddit (OP)

It not works for everyone. Also if depends on the type of work.
View on Reddit #168685

starfries@reddit

Nothing, it doesn't work for everyone.
View on Reddit #167040

DragonMiltton@reddit

Professors don't teach to the lowest of the class, that's just not how university profs generally frame their teaching from my experienced. As a first project it seems reasonable. It's not the trivial examples, which is important because professors want to challenge their students and make them think about the problem for more than just a few minutes.
View on Reddit #166478

value_counts@reddit (OP)

True. Still there are many things to ponder upon and think critically. I will design an AI but not this bitch
View on Reddit #166653

jameson71@reddit

My class was talk about the factorial in the class and the project was the towers. Seemed good to me 35 years ago and I still see no problem with it. But that was with a very good teacher.
View on Reddit #158970

Idgo211@reddit

That's how mine was two years ago and it also was fine! I think it's the right way to introduce that. ToH is easy to figure out when you have the "hint" of having it called a recursion project
View on Reddit #164362

pigvwu@reddit

What would be a good way to introduce recursion?
View on Reddit #156303

5hakehar@reddit

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? ”
View on Reddit #161253

Anfros@reddit

That last point is basically why schools teach you how to do things the hard way. Sure I'll probably never have to do arithmetic without a calculator in real life but learning the methods and algorithms builds intuition and understanding, and that goes for basically every level of math/programming/whatever.
View on Reddit #169406

Kazumara@reddit

Judging from my Algorithms Lab class, the answer is an enormous amount of work for not that many credits, loads of pain, two 6h tests and a high failure rate.
View on Reddit #167341

Flruf@reddit

That last part is especially important.
View on Reddit #165681

1337GameDev@reddit

Yup. Most code in the real world needs 6 things (in this order): 1. Completes the task desired 2. Be easy to understand 3. Run in reasonable time (which is nowhere near optimal) 4. Be designed so that it can be extended in the future 5. Can be tested (eg: moq) 6. Be interesting, clever or fun to look at / work with Most code is not optimal, but performs well enough, easy to understand and is boring as hell....
View on Reddit #167528

MagicSquare8-9@reddit

IMHO, the point of simple solution first is to teach student to be comfortable with the idea that recursion is nothing weird or unintuitive. Many new students think recursion as this black magic, but they intuitively get loop. But recursion and loop are the same thing, just written differently. Sometimes people translate between the 2 without even thinking, e.g. the Fibonacci number problem: the direct method would be recursion, but most people think of a loop. Then once student get recursion, show them a problem that isn't obviously a loop.
View on Reddit #161424

TheMcDucky@reddit

Recursion isn't just a different way of writing loops; it's a method of solving a problem. You don't need recursive function calls to apply recursion. But I agree that this should be clarified to learners.
View on Reddit #162862

MagicSquare8-9@reddit

>You don't need recursive function calls to apply recursion. Are you using "recursion" in the general sense of any algorithms? Because in the context of programming, recursion do mean you use recursive function call.
View on Reddit #166720

deirdresm@reddit

> The game is incredibly hard to even look at when given 10 disks. How would you start? Odd: put the top disk of the stack you want to move on the stack you want to (eventually) move it to. Even: put the top disk of the stack you want to move on the stack you *don't* want to (eventually) move it to. This works even for sub-stacks.
View on Reddit #157783

SigmaMelody@reddit

We’re not interviewing you, you’re safe, you can relax
View on Reddit #162492

deirdresm@reddit

Thank you, I needed to hear that. (Rough week.) ObHumor: once upon a time, I answered the "Why are manhole covers round?" question with: "Because manholes are round."
View on Reddit #166488

SigmaMelody@reddit

Yeah. I fucking hate interviewing and having to be constantly performing
View on Reddit #166620

deirdresm@reddit

Almost went through that again this week as there was some confusion about whether my contract was being renewed or not. So glad it was. Love the team, the work's interesting, and the pay is great.
View on Reddit #166669

i_waited_8_minutes@reddit

Good job completely missing the point of the comment
View on Reddit #159044

NvidiaRTX@reddit

He got PTSD from all the interviews and answered instinctively lol
View on Reddit #164711

saphoratia@reddit

missed the point but ty for teachin me
View on Reddit #160116

oldsecondhand@reddit

IMHO tree traversing is the perfect way to teach recursion. It's simple enough, but doing with a loop wouldn't be simpler.
View on Reddit #166256

ayriuss@reddit

Binary search was my favorite recursive problem.
View on Reddit #165079

ayriuss@reddit

The awesome thing about recursion is that a if you can recursively solve for 3 discs, it will work for any number (maybe not specifically but ykwim)
View on Reddit #165055

blaineworld-bph@reddit

What does TOH stand for?
View on Reddit #156752

Shrekowski@reddit

So not The Owl House
View on Reddit #161463

flukelee@reddit

I also thought owl house and was even more confused:)
View on Reddit #164800

zyxwvu28@reddit

Same lol. Luckily I recognized the game and realized they were talking about Towers of Hanoi
View on Reddit #179791

HeadToToePatagucci@reddit

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.
View on Reddit #156952

Lipstickvomit@reddit

> with the constraint that you can never put a larger disc on a smaller disc. Not only that, you can't place a different shape on a stack, even if said shape is smaller than the shape it is placed upon.
View on Reddit #159573

MattieShoes@reddit

... wat. They're all discs
View on Reddit #160688

SlenderSmurf@reddit

maybe he played 3D tower of hanoi
View on Reddit #162192

DigitalUnlimited@reddit

Simtower of Hanoi.
View on Reddit #168481

Lipstickvomit@reddit

Exactly, you can't put a different shape on top.
View on Reddit #167984

Fishanz@reddit

_make the disk go in the cone_
View on Reddit #163927

ctrl2@reddit

This problem is called the [Towers of Hanoi](https://en.wikipedia.org/wiki/Tower_of_Hanoi)
View on Reddit #156917

Thenderick@reddit

We needed to make a Sudoku solver with backtracking for our final recursion assignment. When you understand recyrsion it's pretty doable
View on Reddit #170025

RoboZoomDax@reddit

Of course factorials are easier. But it doesn’t teach recursion as effectively.
View on Reddit #164875

value_counts@reddit (OP)

The core concept to learn in recursion is what? That some functions needs to be called themselves recursively till a basic condition is met. And once the condition is met, all the calls fold back in the same order on which they were called. That I learn in any number of problems. But not this bitch
View on Reddit #166727

RoboZoomDax@reddit

That’s not how I’d characterize it… I’d argue that in learning recursion you first need to show the tool (ie syntax and mechanics of recursion) and the problems which are best solved by this tool. This requires building a problem that is conceptually much much stronger being solved by recursion than any other method. A factorial, for example, could be a for loop - recursion doesn’t really provide any unique problem solving value. ToH is extremely unwieldy in any implementation other than recursion, very effectively showing a student the power of this tool and your an entire class of problems can be best solved this technique in the wild. You’re confusing the syntax of recursion with the greater lesson of understanding the unique class of problems solved by recursion.
View on Reddit #169369

Tipart@reddit

Pretty sure recursion is actually slower than a normal implementation for TOH, but I could be remembering that wrong.
View on Reddit #155016

Broodking@reddit

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.
View on Reddit #155638

iloveuranus@reddit

Yeah the recursion variant is most likely a lot more elegant - i.e. very succinct and readable. I always love when I stumble across a problem where recursion is genuinely the best solution, but it almost never happens in day-to-day work.
View on Reddit #159951

narwhal_breeder@reddit

After 7 years I can count on one hand times when recursion has genuinely been the best solution, almost always with tree like structures.
View on Reddit #165422

iloveuranus@reddit

Agree 100%
View on Reddit #169279

nonicethingsforus@reddit

I'll add parsing, too. Recursive descent parsers and parser combinators can be surprisingly useful in the correct context. My area is more to the system administration side. Lots and lots of shell scripts with judicious and barely barely documented use of sed and awk. More than once I've been able to rewrite a frankensteinian mess into a simple parser in Python. The parser, and navigating the resulting tree-like structure, are all naturally recursive. But yes, it helps that I can change between recursion and `for` when needed. The right tool for the job and all that.
View on Reddit #168681

CommitteeNo6533@reddit

Earnest curiosity, handling paging on API calls, e.g., doing a "full load" into a table and only Access is API with 500 record limit per call. I suppose a "while i < lastpage", but if you don't get a last page# simply a nextPageUrl?
View on Reddit #167335

imaginarypornbot@reddit

I am a tools programmer and this is exactly when I use recursion. So few lines of code to walk the whole tree
View on Reddit #166477

shouldbebabysitting@reddit

If blowing the stack is an advantage.
View on Reddit #158893

snamellit@reddit

In many iterative variants of recursive algirithms you still need to store intermediate state on self-managed stack, which can also blow up. With recursive calls you get that state management for free (which can be a blessing or a curse).
View on Reddit #169072

nonicethingsforus@reddit

Many languages, especially newer ones (e. g., Go), or that like recursion (e. g. many scheme implementations) have "dynamic" stacks that grow with the program. They blow up as with normal heap-allocated memory: when the memory runs out, or the OS-imposed limits kill the process. Also, most recursive solutions don't involve *that* many recursions. The point of many recursive problems, or data structures that are naturally recursive (e. g., search trees) is that the problem is reduced with every recursion, or at least limit the maximum depth of the search space. If you're doing "normal" stuff like parsing web pages, filesystems, abstract syntax trees, etc., you will not be blowing many stacks. Stacks are mostly broken with more numeric and "academic" exercises. Factorials and the like. If you really find these in the real world, then I concede: you'll probably be better off going for an iterative solution, in a language more suited for them. And lastly, recursion can *really* simplify some problems in the real world. There's a reason why it's often said in parsing/compiler circles that the *only* kind of parser you should be doing by hand has ["recursive"](https://en.wikipedia.org/wiki/Recursive_descent_parser) in its name, and why there's an entire [lambda paper](https://en.wikipedia.org/wiki/History_of_the_Scheme_programming_language#The_Lambda_Papers) on [how recursion simplifies state machines](https://dspace.mit.edu/handle/1721.1/5753). When you know in what kinds of problems recursion is appropriate, believe me, you *miss* them when a language puts bumps on it. I'm still salty on that time I had to use a stack by hand in async Rust just to parse damn HTML... not fun.
View on Reddit #168519

Coaderium@reddit

A smart compiler doesn't allocate a new stack frame for properly implemented tail call recursion, it just reuses the recursive function's one over and over.
View on Reddit #159084

nonicethingsforus@reddit

Even assuming you are using a language that does proper tail call optimization (and that's a whole can of worms), tail recursion only kicks in if the solution is in proper tail call form (the recursion is in the tail position). Many "elegant" recursive solutions are not tail recursive. Every recursion can be transformed into an iteration, and every iteration into a tail recursion, but it's more work and sometimes you lose the simplicity and elegance that recursion is supposed to give in the first place (this is subjective, of course). If you're using a recursive solution, it's normally because you've decided the cost in efficiency is worth the readability and you're not likely to run out of resources (both are very likely the case, more times than premature optimizers would want to admit). You're also probably using a high level, even functional language where the trade off was made from the get-go. Also transforming a recursion to an iteration often involves manually creating your own stack *anyway*. And add to this the fact that many languages have a "dynamic" stack that grows when needed and won't blow up (before your memory or OS imposed limits, at least. I know modern languages like Go and languages that like recursion like some Lisps/Schemes do this). The recursive solution will be clearer, easier to write, and not *that* different from the iterative/tail recursive version at the low level. So yeah, tail recursion is not always a good answer to "it's less efficient." But, let's be honest, most applications don't need assembly-level optimization. The time savings and readability gains are almost always worth it.
View on Reddit #168201

orbital_narwhal@reddit

All iterative algorithms can be restated as tail-recursive algorithms since the two are computationally equivalent. But not all all recursive algorithms have that property, not even if we exclude double recursion etc. (e. g. quick search).
View on Reddit #162841

RootsNextInKin@reddit

Unless the programming language forbids/doesn't have tail recursion primitives required... Then we just suffer because the language isn't quite there yet (or maybe never will be because it was deemed unnecessary)
View on Reddit #159319

undermark5@reddit

Then one could argue that you're using the wrong language for solving said problem recursively. Languages themselves are also tools (i guess more like a toolbox full of tools, but still...), if the way you are implementing your solution requires primitives that the language doesn't provide it's kinda like trying to hammer a nail with a screwdriver, will it work? Maybe. Will it be easy? No. Instead try to find the solution that uses a screw instead of a nail because you've got a screwdriver not a hammer.
View on Reddit #161689

zeropointcorp@reddit

Tail recursion is a thing
View on Reddit #164359

jameson71@reddit

Being more elegant used to be considered an advantage.
View on Reddit #159004

dasgudshit@reddit

If it's not then why do we have entire website dedicated to it?
View on Reddit #158989

SuitableDragonfly@reddit

All tail-recursive algorithms can be rewritten as loops. Non-tail-recursive problems can't.
View on Reddit #166673

ayriuss@reddit

Its sometimes a difference of O(logn) vs O(n).
View on Reddit #165120

HildartheDorf@reddit

All basic recursion can be turned into a stack based solution using the built in hardware stack almost every microprocessor has nowadays. More complex recursion problems will need additional stacks creating (typically as structures on the 'heap' or whatever your language of choice uses), but it can still be converted.
View on Reddit #160235

zeropointcorp@reddit

I mean I guess you’re aware, but the problem is that if you can’t convert it into tail recursion, you’ve introduced a limit on how many recursions you can do (based on memory available), which is a limit that wouldn’t exist if you were processing it iteratively, as the iterative case would not need to allocate memory for each loop. Practically it may make no difference for the particular problem you’re solving, but depending on the language it may fail entirely (for example Tcl had a quite small stack limit that would screw up many recursive solutions).
View on Reddit #164467

leftsharkfuckedurmum@reddit

And (as I'm sure you're aware) compilers will often optimize recursion into iteration, specifically if tail recursion is used
View on Reddit #159695

XkF21WNJ@reddit

You might be remembering wrong, the recursive algorithm uses an optimal set of moves.
View on Reddit #160943

dingdongdinger1@reddit

Both solutions use the optimal set of moves - that's what makes them solutions. The non-recursive solutions calculate the moves faster.l/with less memory.
View on Reddit #162882

XkF21WNJ@reddit

There are solutions that do not use the optimal sequence of moves. You could simply traverse the state graph depth-first for instance. But once you have a solution that calculates the optimal set of moves in a simple straightforward manner then trying to optimize beyond that is precisely the kind of premature optimization that is said to be the root of all evil.
View on Reddit #163173

dingdongdinger1@reddit

Having obtained the optimal set of moves the only thing *left to do* is to optimise for performance. That's not premature at all.
View on Reddit #163488

xebecv@reddit

Recursion can actually be pretty fast, as stack allocation is a noop. It's much easier to make a fast recursive solution than to make a fast iterative one
View on Reddit #163395

CallMeAnanda@reddit

As was said elsewhere, you need a benchmark and a business reason to make code that’s more performant and harder to understand.
View on Reddit #156195

UniKornUpTheSky@reddit

Thanks for saying it. What is even the point of having ultra performant solution anymore on very simple problems until you deal with conditions that require it ? Is it really better to spend thrice (if not more) time making it and about the same teaching, monitoring, debugging and commenting it ? Complex solutions are the starting point of everything. Then people start to simplify them to spread the knowledge. Then people with different mindsets finally understand the solution and can bring useful insight on new ways to better it/add something useful. Biggest example I could have in mind is making electricity : began with manual movements, then adding mechanics to help. Then they tried to use heating water to make engines run which produce movement. It then split up in several ways : 1. How do we make heating water more cost efficient 2. What energy can we use else of heating water to have movement or produce electricity. On the 1st you'll have basically every type of power plants (gaz, coal, nuclear) still getting bettered with nuclear fusion On the 2nd you have wind, solar, etc. All different kinds of engineers have now the possibility to work on the "energy creation" problems.
View on Reddit #161831

Justwatcher124@reddit

Not necessarily, for distributed systems / computing, where there are many tasks that can be done at the same time (meaning being able to use multiple or even alot of CPU-Threads) programming those tasks recursively can split the tasks way more easily for the CPU and thus make use of multi-core or multi-thread CPU's. To be clear - not all questions are easier when answered recursively, but some can be sped up by factors of recursions per recursion.
View on Reddit #160148

Peptuck@reddit

I've never been able to write a TOH code that wasn't a spaghetti mess that induced madness in all who looked upon it.
View on Reddit #160198

DigitalUnlimited@reddit

That's all my code...
View on Reddit #168493

TrippyDe@reddit

factorials is the way
View on Reddit #168446

Psyll@reddit

I had to build TOH, with a “gui” (read: ascii terminal GUI) using assembly (MIPS) for my computer architecture final project. Fuck that.
View on Reddit #166773

value_counts@reddit (OP)

It was a real challenge though. Was it a group project?
View on Reddit #166914

Psyll@reddit

A group of 4, though I somehow managed to be the only one with commits to our repo. One guy did nothing, one guy did documentation, and the last kinds spitballed with me while I coded it out (he was a close friend). It was a good challenge, and tbh the course taught me a lot. Glad to have taken it, but also glad to have never needed most of that knowledge at work.
View on Reddit #166940

yottalogical@reddit

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.
View on Reddit #160675

ItselfSurprised05@reddit

> Factorial is definitely a simpler problem, but it's also pretty easy to implement without recursion. The problem with using factorial as an example for recursion is that they way you learn them has nothing to do with recursion. So you kind of force recursion into it. IMHO, the easiest way to understand recursion is when recursion is present in the definition of the problem. The only real world scenario in which I have encountered recursion was when I was building something to inventory the contents of a network share. Basically the definition of the inventory routine is to start in a given folder, get each files and subfolder in that folder, and then for each subfolder run the inventory routine. Recursion presents itself as a solution.
View on Reddit #163427

Bakoro@reddit

Tree structures (like files) are a hella practical way to teach recursion.
View on Reddit #166531

FlyByPC@reddit

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.
View on Reddit #164881

ntldr@reddit

I'm with you, sorting a list is a good way of learning recursion. TOH was just a mindfuck.
View on Reddit #162920

JustAGuyWhoGuitars@reddit

I think the struggle is part of learning. If you had said "I didn't struggle with it", would you have really learned much? The more you struggle, the more you learn, IMO. You have to learn to enjoy the struggle instead of being like "struggle is uncomfortable and I don't like it".
View on Reddit #162346

Svhmj@reddit

Recursion didn't really click for me until a teacher drew a call stack in the whiteboard. That's a method I strongly recommend.
View on Reddit #161574

Isthisworking2000@reddit

My first intro class used logo and I loved using fractals for drawing things (usually got me a lot of extra credit), they felt perfectly natural. But that dog’s picture is genuinely how I feel about those stupid towers.
View on Reddit #160585

mikewirkijowski@reddit

Factorial is the simplest 3 lines of code you’ll ever see if you understand recursion and what factorials are, im not sure thats a great compariso
View on Reddit #160547

polkiujh@reddit

TOH is a good exercise because it is extremely easy if you properly understand recursive reasoning, and extremely hard if you don't. It's a very good way to tell apart the students who are still just unfolding the recursive calls as a loop in their head. They will be able to write a factorial function, but will implode when they see the towers of hanoi solution
View on Reddit #159989

Dear_Philosophy9752@reddit

Skill issue
View on Reddit #159614

MrZerodayz@reddit

The optimal solution uses recursion afaik, but that's about it. I still prefer the Fibonacci sequence to teach it to people.
View on Reddit #177864

Dracnor-@reddit

Depends. Are you teaching to CS students ? Then absolutely, recursion provides a very simple solution to a seemingly hard problem, that emphasizes on the very idea of recursion : reduction to the same problem but on a smaller size. Are you teaching to math students ? Then maybe stick to what they know : computing integer/real sequences like factorial or Fibonacci.
View on Reddit #169901

DeMonstaMan@reddit

No goddamn way. Best way of teaching recursion is factorial
View on Reddit #157380

Pierre_from_Lyon@reddit

Fibonacci imo
View on Reddit #159282

quadraspididilis@reddit

Not a fan since the recursive solution is so wasteful for Fibonacci. Like “alright class, today we’re going to learn a new concept by writing some code that barely works, you should never do it this way” I was distracted the whole time trying to figure out why we were learning this at all.
View on Reddit #162193

Pierre_from_Lyon@reddit

Well thinking about performance when you're confronted with recursion for the first time is quite unusual i would say. Fibonacci is a really great way to demonstrate the mathematical concept of it imo.
View on Reddit #169367

quadraspididilis@reddit

Honestly I think what actually happened was it was a homework assignment and I discovered that the algorithm became useless before 50 digits. Sure, from a purely mathematical perspective I guess it’s perfect but from a computer science one I think it demonstrates the failures of the concept rather than the virtues.
View on Reddit #169750

goddess_steffi_graf@reddit

but using recursion in factorial seems kind of weird.. because you can easily calculate it using a loop. i think, the best example of recursion is various functions related to trees.. insert node, find max depth, etc. etc.
View on Reddit #158691

DeMonstaMan@reddit

You dont understand. Factorial is the best way to teach recursion because it's easy to grasp content-wise. The fact that you're learning recursion implies you have good hold of iterative calculations in for loops, so toh first ask the student to code factorial using a for loop (optional) then you show them how 1 line of code which calls a function within a function can solve it
View on Reddit #158977

HarryPlopperOMG@reddit

What is TOH?
View on Reddit #158368

HolyMackerelIsOP@reddit

The Owl House.
View on Reddit #169199

510Threaded@reddit

Tower of Hanoi
View on Reddit #158646

tecberth@reddit

My teacher said, "if wanted to kill all of you, I would kill one of you and the remaining, until all of you were killed. There all of you would find the starting condition, the problem reduction clause and the finishing condition. "
View on Reddit #168919

jdog320@reddit

the two ways I was able to understand recursion was through divide and conquer, cofactor expansion in lalgebra
View on Reddit #168318

GreenOnion94@reddit

My first recurring recursion project was factorials! It was a great very first introducing
View on Reddit #167603

lefixx@reddit

Yes, If you explain it right, or better yet, if you find the explanation that works for you.
View on Reddit #166764

30MHz@reddit

Abbreviating Towers of Hanoi as TOH is pretentious af
View on Reddit #166511

Chingiz11@reddit

Nah, Fibonacci numbers and factorials are way better for beginners, although TOH is really good for mastering recursion
View on Reddit #158487

dagbrown@reddit

If anything, given the combinatorial explosions involved, Fibonacci numbers are a way better way to explain the power of memoization than to explain the power of recursion.
View on Reddit #162728

JoieDe_Vivre_@reddit

But you kinda need to understand the recursive solution first, and then show why memoization is helpful.
View on Reddit #165559

goddess_steffi_graf@reddit

Fibonacci 🤔 virgin recursion 😭 vs chad "a += (b += a)" 😎
View on Reddit #158812

Kinglink@reddit

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....
View on Reddit #157487

ina300@reddit

Best way of thinking about it
View on Reddit #158723

Kinglink@reddit

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.
View on Reddit #159371

Atora@reddit

I severely doubt you can manage even a 100 disks. That's 2^100 - 1 moves(=10^30 ). If you can compute a billion moves a second you'd still need over 10^13 years.
View on Reddit #161360

FlyByPC@reddit

Yes, but the first move will be to move the top disc to the spare stack (the stack that isn't the goal.)
View on Reddit #164845

Glugstar@reddit

It's not about evaluating that many moves, it's about being theoretically able to evaluate that many moves if you had the time and computational power. In other words, your algorithm needs to be correct, otherwise it's very sloppy programming which quickly delves into maintenance nightmare. Solutions that were hacked together to work only with a subset of possible input data quickly acumulate. It can rapidly turn into technical debt which can ultimately doom your company. Not to mention that because it's wrong, maintenance will take 10x time to debug, because whoever comes after you will scratch their head trying to understand if it's built that way on purpose (because there's some technical reason why it was implemented that way), or it's just a bug.
View on Reddit #161741

quadraspididilis@reddit

To me the fact that the target peg keeps changing makes it confusing to express recursively so it’s not the problem I’d use to introduce someone to the concept of recursion. Like you’re introducing an extra step where the person has to understand the puzzle first whereas doing factorial recursively makes more sense because the problem is easy to understand. I get why people use TOH but to me it makes understanding recursion harder than it needs to be.
View on Reddit #161647

Kinglink@reddit

The target peg changes, but that shows how the function can evolve over time, and can be used for multiple calls or functions. Might not be "baby's first recursion" but it's an excellent problem to solve with recursion.
View on Reddit #162278

quadraspididilis@reddit

Oh I agree with that, I was thinking the question was if I had to teach someone of recursion for the first time like they’d never heard of the concept before.
View on Reddit #162317

B4-711@reddit

I solved it for one disk but my algorithm isn't working.
View on Reddit #160695

CrabbyBlueberry@reddit

Yes. Source:
View on Reddit #164682

Xuval@reddit

Recursion isn't even a great concept to teach. If you put that into your 1o1 lessons for programming your encourage people to use recursive programming as "the way to do it", even if it is often a very ressource-inefficient way to solve a given problem.
View on Reddit #158978

Shmodecious@reddit

It should be taught with caveats, but it is absolutely a good thing to teach.
View on Reddit #159088

dotslashpunk@reddit

absolutely, but i tend to avoid it because it can make functions somewhat confusing. That said it’s absolutely needed sometimes.
View on Reddit #164209

helix400@reddit

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 pain loops and a manual stack.
View on Reddit #159143

pavlov_and_his_bell@reddit

For real, building your own binary search tree is a much better way to learn recursion. You get to learn about binary search trees and have to use recursion at the same time. That’s how I was taught at the end of my first semester in Uni
View on Reddit #163479

Flockwit@reddit

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.
View on Reddit #162386

Neither_Interaction9@reddit

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
View on Reddit #154568

lonnie123@reddit

This was the problem that made me drop out of programming class in college. It was presented to us in week two with almost no instruction (I think the teacher later got moved out of the class) but I couldn’t figure it out and dropped it. This was about 20 years ago so the internet wasn’t as helpful as it might have been today
View on Reddit #163458

RajjSinghh@reddit

It's one of the go-to examples, but I would probably go to factorials, fibonacci or either quicksort or mergesort first. In the end it's up for you to decide. The solution is actually really tidy. Let's say you have n disks and call the pegs A, B and C, where we start on peg A and have to move to C. To do this, we first move n-1 disks from A to B so we can access the largest disk. We then move that largest disk to C to place it the correct spot. We then recursively call this procedure to move the n-1 disks from B to C using A as the empty peg. This means moving n-2 from B to A, the disk on B to C and then recursively calling to move the disks on A to C through B. We recurse until we reach zero, as moving no disks is trivial. [Here is a relevant computerphile video where they implement it in python](https://youtu.be/8lhxIOAfDss).
View on Reddit #163129

Flexo__Rodriguez@reddit

No. It fucking sucks. I understand recursion but have never understood how the base case here works.
View on Reddit #162720

Qibble@reddit

Robozzle?
View on Reddit #162388

CptMisterNibbles@reddit

No, it really just isn’t. Certainly not a basic example, and should not *absolutely* not be the go to example for introducing the topic, yet frequently is.
View on Reddit #158936

SociableFish97@reddit

The progression of teaching recursion should be: 1. Saying that recursion may not be the best way to solve a problem 2. Using recursion to find out what 1+2+...+(n-1)+n is 3. Using recursion to find out what n! is 4. Using recursion to find out what the nth Fibonacci number is 5. Using recursion to traverse a tree using DFS 6. Using recursion to find a solution to the Tower of Hanoi puzzle
View on Reddit #161792

CptMisterNibbles@reddit

An excellent progression. While showing the iterative equivalent in each step maybe.
View on Reddit #161891

SociableFish97@reddit

Good addon, except what is the iterative Tower of Hanoi solution?
View on Reddit #162210

CptMisterNibbles@reddit

Stack based, verbose, and ugly. Going over ToH recursively last is a great way to show *when* recursive solutions may be the better choice.
View on Reddit #162263

_-TheTruth-_@reddit

I found linked lists and binary trees to be very effective at teaching recursive.
View on Reddit #157557

quadraspididilis@reddit

Binary tress are great because I’m not even sure how I would express traversing one without recursion but the structure is so obviously self similar the recursive solution is easy.
View on Reddit #161995

Ruin369@reddit

It's definitely a more complex example, so probably not. I would say factorial is the easiest example of recursion IMO
View on Reddit #157232

Glugstar@reddit

It's an example of recursion, but not a good one. The idea of recursion is to be able to solve a problem without knowing a complete solution to the problem. If you already know how to solve it, recursion is usually a bad tool.
View on Reddit #161793

bitsplease-@reddit

Fibbonaci sequences is what made it "click" for me
View on Reddit #160496

WideSavings129@reddit

Just doing recursion is how I learned to understand. TOH confused me so much
View on Reddit #161519

Mercurionio@reddit

Recursion 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 =\\
View on Reddit #155241

Tsu_Dho_Namh@reddit

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.
View on Reddit #157984

Mercurionio@reddit

I mean, I understand the logic. But if you asked me to write it right now - I would be that doggo.
View on Reddit #158135

Tsu_Dho_Namh@reddit

I'll give it a crack. def solve(n , source, goal, auxiliary): if n==1: print ("Move disk 1 from",source,"to",goal) return solve(n-1, source, auxiliary, goal) print ("Move disk",n,"from",source,"to",goal) solve(n-1, auxiliary, goal, source) solve (3, "Tower 1", "Tower 3", "Tower 2")
View on Reddit #158299

jakerman999@reddit

Wonder if this bot still works... +/u/CompileBot python def solve(n , source, goal, auxiliary): if n==1: print ("Move disk 1 from",source,"to",goal) else: solve(n-1, source, auxiliary, goal) print ("Move disk",n,"from",source,"to",goal) solve(n-1, auxiliary, goal, source) solve (3, "Tower 1", "Tower 3", "Tower 2")
View on Reddit #158768

BeautifulType@reddit

Ok now ask chat gpt to write the solve in python
View on Reddit #159697

jakerman999@reddit

> Certainly! Here's a Python implementation of the Tower of Hanoi problem using recursion: def tower_of_hanoi(n, from_rod, to_rod, aux_rod): if n == 1: print("Move disk 1 from rod", from_rod, "to rod", to_rod) return tower_of_hanoi(n-1, from_rod, aux_rod, to_rod) print("Move disk", n, "from rod", from_rod, "to rod", to_rod) tower_of_hanoi(n-1, aux_rod, to_rod, from_rod) n = 3 tower_of_hanoi(n, 'A', 'C', 'B') > In the above code, n represents the number of disks, from_rod, to_rod, and aux_rod represent the three rods. > The function tower_of_hanoi takes in four arguments. If there is only one disk, it simply moves the disk from the source rod to the destination rod. If there are more than one disk, it recursively calls the tower_of_hanoi function for n-1 disks and moves the remaining disk to the destination rod. > Finally, we call the tower_of_hanoi function with the number of disks and the source, destination, and auxiliary rods. > Running the above code with n=3 should produce the following output: Move disk 1 from rod A to rod C Move disk 2 from rod A to rod B Move disk 1 from rod C to rod B Move disk 3 from rod A to rod C Move disk 1 from rod B to rod A Move disk 2 from rod B to rod C Move disk 1 from rod A to rod C
View on Reddit #161258

Orkleth@reddit

There are better ways of teaching recursion. Towers of Hanoi is better at teaching graph generation and traversal and using DFS and BFS to find a solution.
View on Reddit #161042

SasparillaTango@reddit

no.
View on Reddit #161035

RegularOps@reddit

No, Fibonacci sequence is better
View on Reddit #160721

lxnxx@reddit

Yes, it is great. Factorial is too trivial and Fibonacci is too slow. Hanoi is a problem that has no obvious algorithm, but it becomes easy if you actually *think* recursively.
View on Reddit #160666

Positive-Vase-Flower@reddit

Hell no. Its a terrible example.
View on Reddit #160588

Handzeep@reddit

The best way of learning recursion I've found is the book The Little Schemer. It never tells you outright what it is. But it keeps asking you questions which lead you to figuring it out yourself. It starts of very easy and if you stick with it to the end it gets as advanced as writing a y combinator. I can strongly recommend the book if you want to learn strong practical fundamentals for recursion. Also there's no need to be scared by the scheme language. It requires no prior knowledge of the language and you'll spend almost no time at all learning it throughout the book.
View on Reddit #159766

Creatura@reddit

NOT AT ALL, NO
View on Reddit #159705

reptar20c@reddit

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.
View on Reddit #159429

Garrosh@reddit

Step one: Write a function that lists the content of a list of objets like this: class MyObject { public string Name { get; set; } } Step two: Modify the class so every object can store a list of its own objets: class MyObject { public string Name { get; set; } public List<MyObject> Content { get; set; } } Modify your function so it list the content of the list and the content of every sub-object. This is a clear example where recursion is the best and most obvious answer. IMHO asking a student to use recursion to solve a problem that could be easily solved without it is counterproductive and stupid.
View on Reddit #159381

save_the_its_pronoun@reddit

>ToH: Tower of Hanoi
View on Reddit #159295

Sexual_tomato@reddit

Simple filesystem search made more sense to me
View on Reddit #158784

IBJON@reddit

Poor for teaching, but may be good for reinforcing the concepts.
View on Reddit #157982

Tsu_Dho_Namh@reddit

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
View on Reddit #157786

Dyanpanda@reddit

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
View on Reddit #159026

ingannilo@reddit

Maybe that’s why I’m not scared of TOH. This post confused me, but I’d seen this as a kid’s game so much that when I bumped into it as one of my first induction problems in a pre calc book it was a quick (but fun) exercise. Maybe today’s CS students had less exposure as kids?
View on Reddit #171653

Dyanpanda@reddit

You saw this in a pre-calculus class? This is a recursion/iteration issue. How was it presented as calc? Also, I think its not that rare in games still.
View on Reddit #175548

ingannilo@reddit

We talked about induction in my precalc/trig class. Prof gave me a copy of the Dover book Challenging Problems in Algebra. It's in there.
View on Reddit #177142

reddit_beepbeeprobot@reddit

I'd teach them recursion first
View on Reddit #157785

Archangel3d@reddit

Yeah but before that you have to teach them recursion or it just doesn't work.
View on Reddit #160791

Siethron@reddit

Personally I would teach them about escape conditions before recursion
View on Reddit #162837

Firemorfox@reddit

But you have to teach recursion before you can explain escape conditions in recursion!
View on Reddit #165921

Original-ish_Name@reddit

You forgot to teach them about systems running out of memory!
View on Reddit #170642

Drakoo_The_Rat@reddit

eh wasnt that bad. Just mildly annoying at first with how imposibly ineficient it is. Like JUST LET ME USE A FOR, THIS COULD BE SO EASY
View on Reddit #168981

Solareon_@reddit

I just call it f(x) on steroids
View on Reddit #168704

windcape@reddit

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
View on Reddit #159082

afito@reddit

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 for office use, you almost always need recursion even if only for the file search.
View on Reddit #164095

yankeeFireWhiskey@reddit

I've been an engineer for a decade and have used recursion a total of 0 times in my work.
View on Reddit #168101

GreenCloakGuy@reddit

I use recursion quite a lot. Not in a mathematical sense, exactly, but the idea that methods can have loops that end up calling themselves. For example, one project I work on is essentially an interpreter for a domain-specific control language - the user can configure a linear formula with a set of steps, including steps that use the results of previous steps, or steps that take the value of other formulas. The way we implement this is absolutely recursive - `executeStep()` for a [step that uses the result of a previous step] will call `executeStep()` on the referenced step, which may in turn call `executeStep()` again, etc. Similarly, `executeStep()` for a [step that invokes another formula] will end up calling `executeFormula()`, which will have its own many `executeStep()` calls, and etc.
View on Reddit #166903

InvertibleMatrix@reddit

> School really did focus on all the wrong concepts Only if you see university as a job pre-requisite. Many of us who want to actually learn the *science* and *math* behind computers would be very annoyed at a CS degree being "dumbed down" to a "software development" degree that's basically just a trade school curriculum that teaches stuff you ought to learn in your first job/internship.
View on Reddit #164023

Twistedtraceur@reddit

I learned it using fibanocci. Way easy imo.
View on Reddit #167388

floyd2168@reddit

Mine used the 8 queens problem.
View on Reddit #165834

RoboZoomDax@reddit

In year 2000 I learned recursion with this problem. Honestly, I think it was a great example for so many reasons. The problem is so easy to understand, the solution is so much better recursively than not, it requires broad thinking. It should stay a learning mainstay for a long time
View on Reddit #164851

aeughfish@reddit

Every Programming / IT teacher on 'How do you teach Recursion to new programmers?'
View on Reddit #163830

lowleveldata@reddit

Process every files in a folder including subfolders is how you teach them. It's actually useful too.
View on Reddit #163214

SkittlesDangerZone@reddit

Man I have always loved recursion. It's that deep level thinking.
View on Reddit #161631

maximovious@reddit

Same. As a young naive junior, I used recursion to do a "fill" in an image, pixel by pixel, and that's when I quickly learned how impractical that is. i.e. change the pixel that was clicked, and then check if its 4 surrounding pixels (top, left, right, bottom) and put those pixels into the same function. Theoretically the recursion would fully complete once the relevant part of the image had been filled. Practically, it crashes with memory complaints, etc.
View on Reddit #163027

OneFootTitan@reddit

It’s called recursion because the newbies curse and recurse trying to solve it
View on Reddit #162733

sweet_tinkerbelle@reddit

Then I went to web development and never did recurssion ever again
View on Reddit #162478

iliekcats-@reddit

Factorialization
View on Reddit #162094

TTYY_20@reddit

Teach them how to write a selection sorting program. You can write one that’s recursive very easily :)
View on Reddit #161609

teems@reddit

Using the Fibonacci sequence is much easier to teach recursion.
View on Reddit #161354

osbombo@reddit

My go to method will always be prolog. Simple, effective, powerful and fun.
View on Reddit #157316

Justwatcher124@reddit

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.
View on Reddit #159875

osbombo@reddit

Fair. Nothing is easier than implementing merge sort in prolog though, and quicksort is also super simple. Makes it easy to teach said algorithms.
View on Reddit #160714

johndoe60610@reddit

My HS CS teacher started off by saying this is a famous problem. My friend and I were like, "cool, let's go to the library after class!" (It was the 80s, no web yet).
View on Reddit #160433

LOTHMT@reddit

Wait how the fuck would you teach recursion with that? We learned it with BinaryTrees in our class last year, but never like this
View on Reddit #159957

Justwatcher124@reddit

This [Computerphile Video](https://youtu.be/8lhxIOAfDss) should make that clear.
View on Reddit #160200

MethodicMarshal@reddit

I'm not a programmer, but is the concern that all the rings on one peg causes a stack overflow?
View on Reddit #159291

hitchenator@reddit

I still find sequences like fibonacci an easier entrance. Still a shit solution, but anyway.
View on Reddit #154648

bleistift2@reddit

A children’s game until you ask your parents how to solve it.
View on Reddit #155194

RedPill115@reddit

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?
View on Reddit #156718

Mortar_Maggot@reddit

I think the point of that one is to teach that we're stronger together.
View on Reddit #157977

Dreadgoat@reddit

It teaches you that the scrawny boy and the underweight girl have the weakest grip and you consistently break their hold by jumping on their arms until they decide not to play anymore because they get a sprain and the coach punishes them for refusing to participate and they become second class citizens for being weaker and lacking state sanctioned authority and you have to pick a new weak pair so you can enjoy winning the game until everyone is sufficiently oppressed and you are the winner
View on Reddit #158397

Onsidianrubucx@reddit

if i had an award u would get it
View on Reddit #187726

Mortar_Maggot@reddit

Yup. Which only means it's a self reinforcing system too. Intention versus result.
View on Reddit #158738

a7n7o7n7y7m7o7u7s@reddit

So recursively reinforced?
View on Reddit #163567

ineyy@reddit

A bit related - parents gave me a Rubik's cube in pre-internet times. And no instructions how to solve it. Insanity.
View on Reddit #166406

Comprehensive_Ebb675@reddit

Wait, you're supposed to get instructions? I thought you had to solve it on your own in the dark if you wanted to eat!
View on Reddit #173003

Iconoclasm89@reddit

r/oddlyspecific
View on Reddit #164700

dotslashpunk@reddit

damn bro. I hope you got on some steroids, got jacked, and went back to all those people and said “red rover me now motherfucker”
View on Reddit #164231

crystalmerchant@reddit

hey dreadgoat you ok man?
View on Reddit #162319

FamiliarPanic@reddit

Scrawny boy checking in, fuck red rover
View on Reddit #161703

KazakhSpy@reddit

Exactly! It teaches you that the chain is only as strong as the weakest link. Sounds like a skill issue if they cant figure out that you dont pair two people with a weak grip together smh.
View on Reddit #160113

BitPoet@reddit

I thought it was just pure chaos.
View on Reddit #158205

Mortar_Maggot@reddit

Nah kids do that naturally
View on Reddit #158753

PantheraLeo04@reddit

It ended up teaching our class about leverage when we realized that if you lift your arms right as they hit it will turn their linear momentum into rotational momentum and they'll get thrown in the air and fall flat on their back
View on Reddit #184793

RedPill115@reddit

Yeah but after you end up on your back a few times, feeling like you got hit by a semi, what did you learn? I learned that when the camp people came around to start a game it was time to make myself scarce. Feeling pike I was going to die for a game I wouldn't remember tomorrow wasn't appealling.
View on Reddit #187528

catinterpreter@reddit

Most of them are just to identify neurological problems.
View on Reddit #164235

Not_MrNice@reddit

Do you think that those games might not exist to teach you that adults will mess with you and that's the reason you don't know what red rover was supposed to teach? "It seems to exist to teach you something." "Oh, what?" "I don't know, like is it supposed to teach you something?"
View on Reddit #162907

ScrabCrab@reddit

Huh, TIL that kids in other countries play that too. In Romania it's called "țară, țară, vrem ostași", which means "country, country, we want soldiers " (but using an old-timey word for soldiers)
View on Reddit #162153

exor15@reddit

I don't think red Rover is "supposed" to teach you anything it's just fun
View on Reddit #159637

Impossible_Garbage_4@reddit

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
View on Reddit #160919

zyzzogeton@reddit

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.
View on Reddit #160272

PooSham@reddit

I had one at my desk while growing up. Every time I was bored of homework I started fiddling with the TOH, and I figured it out eventually. My parents had no idea how to solve it.
View on Reddit #168592

Toxic_Cookie@reddit

That's right! It goes in the the square hole.
View on Reddit #167726

dforderp@reddit

If it’s an odd number, move it to where you want to go. If it’s an even number, move it to the other pole.
View on Reddit #160246

Fartmasterf@reddit

I don't see any numbers
View on Reddit #160457

lotsofpun@reddit

Let me guess, it's just blonde, brunette, redhead?
View on Reddit #165849

Hypersapien@reddit

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.
View on Reddit #164729

SlowWhiteFox@reddit

In a nutshell: solve_problem(problem): simpler_problem = take_one_step(problem) solve_proble(simpler_problem)
View on Reddit #156261

maximovious@reddit

> solve_proble I think the proble is the function's spelling.
View on Reddit #163097

SlowWhiteFox@reddit

That's not a bug. It is a call-out to a helper function. For brevity I didn't include it.
View on Reddit #163388

maximovious@reddit

Could you please explain more? Why the **'proble'** spelling on the 3rd line? I don't get why it would need to be different than the first line, if that spelling was on purpose. Especially in a discussion about recursion.
View on Reddit #164187

Xyphyn@reddit

It's a joke
View on Reddit #175183

maximovious@reddit

Thanks, it went over my head on first read, but realised later and see the humour in it. I'll leave my woosh post there for all to see.
View on Reddit #186761

Xyphyn@reddit

Happy cake day
View on Reddit #186822

Lucky-Earther@reddit

"The proof has been left as an exercise to the reader"
View on Reddit #166099

ironavenger16@reddit

It’s a feature not a bug
View on Reddit #164046

SlowWhiteFox@reddit

I didn't cheat... I changed the conditions of the test.
View on Reddit #166006

TxTechnician@reddit

I've never played with this in programming or irl.
View on Reddit #153387

QuebecGamer2004@reddit

Me neither, I don't really understand this meme
View on Reddit #157199

petascale@reddit

Tower of Hanoi https://en.wikipedia.org/wiki/Tower_of_Hanoi We had it as an example in both mathematics (combinatorics, I think) and programming (recursion), along with the [n-queens puzzle](https://en.wikipedia.org/wiki/Eight_queens_puzzle).
View on Reddit #157375

QuebecGamer2004@reddit

I see, this sounds like more complex concepts that we don't learn in the program I'm in. I'm not in university, I'm in college, so that explains why I haven't seen this
View on Reddit #157764

ArkGuardian@reddit

I hope your program teaches recursion, even if it doesn't use this specific puzzle. If not, it has some fundamental gaps.
View on Reddit #158454

QuebecGamer2004@reddit

Now that I've looked at recursive functions, yeah I remember doing it and know what it is (at least for doing factorials), but it wasn't a main focus. We have a different education system here in Quebec, the program I'm in lasts 3 years and focuses on teaching various skills related to programming and IT, so we can get a job after or go to university if we want. There is another computer science that lasts 2 years but you have to go to university after, and it's more focused on the maths and science instead The main thing we learn is object oriented programming, it's in basically all of my classes, except database ones
View on Reddit #158696

Versatile_Panda@reddit

99% of time in B2C you don’t need recursion, it just doesn’t come up naturally in the real world. Knowing loops in my opinion is plenty, I can’t name more than 5 times I’ve used recursion in my 12 years of work as a dev. Understanding dependency injection which is a completely different thing, is a much better learning opportunity than recursion.
View on Reddit #159499

SeattleSonichus@reddit

Just a hobbyist myself and I’m not sure I get the difference between a loop and recursion. A for loop is pretty simple and works for a lot of things where I’d consider trying to use a method to recall itself. Is the distinction with recursion vs a simple loop just that the method recalls itself?
View on Reddit #163099

aristideau@reddit

There is the same danger with a loop if the exit condition is never met. With recursion if your data structure is faulty you can end up in and infinite loop and blow your stack, but if that’s is a possibility you just put in a check for that and you’re good.
View on Reddit #184915

BrujitaTueTue@reddit

>It just doesn't come up naturally in the real world Trees, graphs, data parsing (JSON), web crawlers are great examples lf real life use of recurssion. It comes very naturally for these problems.
View on Reddit #160118

aristideau@reddit

I got really excited when I had to use it in my first year or so of work to traverse a system menu structure to save its state (menu was dynamic). I got excited because when I was taught it I remember thinking to myself *where the hell and I ever gonna use this?*.
View on Reddit #184806

Versatile_Panda@reddit

I can’t tell you the last time I created a tree myself. In general I have worked front end and backend from react / react native to C# .net and and various things in between m, while I’m sure many of the helper methods I used, did this in some capacity, I basically never had to use recursion. I’m not saying it doesn’t happen, but I struggle to see it as common. If I was hiring new and someone told me and the only part a person struggled with on a skills assessment was recursion I don’t think it would even affect my hiring process.
View on Reddit #173024

nelsonnyan2001@reddit

I think it’s all about familiarity. There are very, _very_ few cases in which recursion is the only solution. There is almost always a less efficient way to do it with loops and conditions. That ends up becoming the norm in the codebase, person approving MR can’t be assed or doesn’t have the know-how to improve on it, less recursion
View on Reddit #160551

kaiveg@reddit

While there often are alternatives, I would argue that recursive problems are best solved with recursive solutions.
View on Reddit #160653

DeliciousWaifood@reddit

I've found that a while loop with List/Stack/Queue can be a really nice alternative in a lot of situations. Especially when you're wanting to do more complex behaviour like tracking the state of nodes, avoiding repeating neighbours etc. People act like recursion is this big scary thing, but imo it's really a tool for more simple math stuff. Recursion just feels too messy and black-box-ish for more complex operations even though you could technically call them "recursive" operations.
View on Reddit #160834

kaiveg@reddit

As I said, there are alternatives that can be used. The question however is should they be used. Non recursive solutions for recursive problems often lead to more bloated and complex code. At the end of the day it comes down to using the right tool for the job.
View on Reddit #161564

B4-711@reddit

learning to be code monkeys for the GNP
View on Reddit #160801

RadicalDog@reddit

I have to say, I'm very comfortable with recursion, but I've never needed to use it outside of Advent of Code. Can't think of a single professional instance where it's been both relevant and the most maintainable way to solve an issue.
View on Reddit #163696

ArkGuardian@reddit

It's useful for recursive structures. This is mostly relevant for indices, json, xml etc
View on Reddit #164608

aristideau@reddit

Once you get your head around it , it is actually quiet intuitive and even though you may not find many chances to use it, when you do it’s a life (line?) saver.
View on Reddit #184605

beaglerehoming@reddit

What’s the difference?
View on Reddit #160139

QuebecGamer2004@reddit

I say college but that's not the right word. Where I live we have primary school (grade 1-6), secondary school (1-5), then we have something called CEGEP which you have to go to before university. It's much cheaper than uni (~$200 per semester) so you can decide if it's for you or not and can easily change fields. In CEGEP there's two types of programs, 2 year ones that require you to go to university after, or 3 year ones that let you decide whether you want to go to work after or go to university
View on Reddit #160571

WolfAkela@reddit

Might be British or from Oceania. College = high school.
View on Reddit #160373

zyzzogeton@reddit

Good god I'm old. This is how we rotated magnetic tapes on and of... Oh no, I see it now. I'm *very old.*
View on Reddit #160304

BornAgain20Fifteen@reddit

> in both mathematics (combinatorics, I think) and programming (recursion) Are you me? Haha
View on Reddit #165675

dutch_master_killa@reddit

I remember this in college and I have forgotten completely what my solution was or what it was even about lol
View on Reddit #164286

Rokey76@reddit

I learned it in college in some computer course. All I remember is the solution is the easy part, but doing the moves would take way longer than a person lives. I don't remember how long it took to execute on a computer.
View on Reddit #159177

PrizeStrawberryOil@reddit

if it takes 3 seconds per move it would take about an hour for the one in the picture to move to another peg if it was stacked properly. This problem is exponential though. (Literally not figuratively) Assume the average person would have 50 years to work on it allowing for sleep. They would have time for 1.44m moves. Log2(144m)=20.45. The tower that you did in college was at least 21 discs.
View on Reddit #159844

DeliciousWaifood@reddit

>If it takes 3 seconds per move it would take about an hour for the one in the picture to move to another peg if it was stacked properly. I don't understand. The picture can be solved in 8 moves
View on Reddit #160890

PrizeStrawberryOil@reddit

The puzzle is to start with a full stack on one peg and then move it to another peg. It's already mostly solved. (or mostly unsolved depending on how you look at it.) Try to move the largest disc to a different peg and solve the puzzle.
View on Reddit #160940

DeliciousWaifood@reddit

And I can only move smaller ones on top of bigger ones right? Yeah, just tried it and the number of moves inflates massively as the stack gets bigger lol
View on Reddit #161093

Rokey76@reddit

I looked on the Wiki for Towers of Hanoi, and the legend was 64 discs which would take 500+ billion years to complete.
View on Reddit #160765

PrizeStrawberryOil@reddit

With 3 seconds per move for 16 hours a day I got 63 discs was over 500 billion years. Tracks for me.
View on Reddit #160971

DeMonstaMan@reddit

Tower of Haoi, it will give yoh ptsd
View on Reddit #157398

BuccellatiExplainsIt@reddit

It's a common project to teach recursion. We had to do it for learning assembly in University.
View on Reddit #160327

_paramedic@reddit

I’ve only done this/seen this done as part of neuropsychological examination
View on Reddit #159326

walrusk@reddit

I think it’s just referring to writing sorting algos. I always enjoyed that actually. Too bad it’s basically never needed in practice.
View on Reddit #158338

tubameister@reddit

I still remember the solution to this on my TI-84 121323123132121323213123121323
View on Reddit #154185

FerynaCZ@reddit

Move the smallest one always in one direction on each odd move, then you are left with only one option on each even move
View on Reddit #157850

Aikon377@reddit

Oh god not recursion
View on Reddit #184912

very_bad_programmer@reddit

To this fucking day I have never encountered a challenge as hard as ToH
View on Reddit #158227

bruhred@reddit

i feel like i got dumber because i was able to come up with algorithm on my own when I was like 10 but i just can't anymore
View on Reddit #165826

very_bad_programmer@reddit

I feel the same, a lot of challenges I was able to overcome when I was new are so much more difficult now. Same with games, dude, I was like 8 when I played Battletoads and I have no clue how I was able to beat it as a child because I definitely can't now
View on Reddit #180533

LuckyCharmsNSoyMilk@reddit

I still don't fully understand it even though I (generally) understand recursion. I just know the algorithm works.
View on Reddit #158840

monocentral@reddit

https://www.reddit.com/r/ProgrammerHumor/comments/121qs09/this_one_never_gets_old/jdnoyjp/
View on Reddit #180480

alt779843@reddit

Say you have n disks in column 1. Suppose that *I* know the method to moving the top n-1 disks from any column to any column, and you can ask me to use that to help with your own solution for the n disks. You want to move the n disks, so obviouly you're going to move the last disk (disk n) at some point, so you decide to focus on the step of moving it to column 3. You tell me to move the n-1 disks from column 1 out of the way to column 2. Then you yourself move disk n to column 3. And finally,you ask me to move the n-1 disks from column 2 to 3, and the solution is done. So it's just 3 steps. But that solution that I know for the n-1 case has the same 3 steps as the n case, but it's n-1 instead of n. And that's the recursion. The code would look something like this: you would define a function called "move" that you pass to it the same pieces of information we used above: How many disks you want to move (n), from which column (start), and to which column (end). You could also pass to it which column is the "extra" column, which would help a bit with writing the code cleanly. So the meat of the function goes like: move(n-1, start, extra, end) #move n-1 disks from the start to the extra move(1, start, end, extra) #move 1 disk from the start to the end move(n-1, extra, end, start) #move the n-1 disks from the extra column to the start And of course, don't forget the base case, which would be when you're moving just 1 disk. Just print out "move the disk from [start] to [end]".
View on Reddit #162209

Jealous-Ninja5463@reddit

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
View on Reddit #161008

LuckyCharmsNSoyMilk@reddit

Fair. I think my biggest blocker with recursion in general is I tend to think about it from the first recursion to the last when really it’s working down to the base case and starting from there.
View on Reddit #161581

Underpowered007@reddit

Just teach the kid how to brute-force
View on Reddit #153685

Vinxhe@reddit

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.
View on Reddit #158856

zyzzogeton@reddit

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.
View on Reddit #160153

338388@reddit

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
View on Reddit #160840

HoroAI@reddit

Trees come to mind. It's just intuitively easier to understand sometimes. The compiler does it's own thing in the end anyway.
View on Reddit #161328

monocentral@reddit

Yep, tree traversal is a good example for useful recursion.
View on Reddit #180363

jagharingenaning@reddit

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.
View on Reddit #161355

Cleanumbrellashooter@reddit

Anything recursive could be written with a loop and a stack as that's all that recursion is doing for you
View on Reddit #162976

Hoivernoh@reddit

Any function can be written as goto and a stack as that’s all that function calls and return do for you.
View on Reddit #165516

GreenCloakGuy@reddit

The biggest benefit of recursion, especially on a large scale, is the fact that each layer has its own isolated scope. For complicated functions in big applications, which can number > 10 unique variables and > 100 lines, it's a lot easier to represent and reason about the logic when it's implemented as a recursive function rather than as a loop.
View on Reddit #166955

Kart0fffelAim@reddit

Just move pieces randomly and treat connected pieces of the same colour as one. That should work eventually
View on Reddit #169345

MadMadBunny@reddit

You mean rip off the three pegs?
View on Reddit #164427

DigitalCryptic@reddit

Take every piece out EZ
View on Reddit #156871

AE_Phoenix@reddit

The real world equivalent of "if the program isn't running it doesn't have any bugs"
View on Reddit #162895

steamyoshi@reddit

A variation on Stalin Sort
View on Reddit #160487

Underpowered007@reddit

Can I use this method for job interviews?
View on Reddit #157749

econ101user@reddit

In the original Xbox there was way to save an image to the frame buffer and restart the whole box. So if you had memory issues in a part of your game you could toss up a loading screen and reload the whole console and game as a hack to start fresh https://hitechglitz.com/morrowind-on-xbox-would-completely-restart-the-console-during-certain-loading-screens/ This is effectively the same technique and has grounding in a successful product If you told me that in an interview I'd say "fair enough" and not deduct anything.
View on Reddit #159685

IBJON@reddit

Depends if they add the stipulation that you can only move one ring at a time, then no. Otherwise, it's just a version of merge sort
View on Reddit #158008

MajorGeneralInternet@reddit

Null gang 🤙🤙🤙
View on Reddit #158167

WisestAirBender@reddit

Recursion is brute force
View on Reddit #158747

Minighost244@reddit

???
View on Reddit #159500

runamonk@reddit

lol
View on Reddit #179373

Reiner_braun123@reddit

Remember learning to solve this using recursion.The tower of hanoi problem.
View on Reddit #178011

iambannedyetagain@reddit

omg ![gif](giphy|wMDizdl57v3zZs2vbQ)
View on Reddit #177241

ReadyThor@reddit

That is not a game for kids. That is a game for an entire lifetime.
View on Reddit #175188

_Cherrryy@reddit

Recursive
View on Reddit #174057

_Cherrryy@reddit

Recursion
View on Reddit #174064

TimingEzaBitch@reddit

Lol vietnam flashback for Hanoi tower. Clever.
View on Reddit #173953

1cingI@reddit

I, honestly, don't know this game. 🧐🧐
View on Reddit #172509

Top-Chemistry5969@reddit

Oh that hurth. Fuck
View on Reddit #172185

Goldcrest25@reddit

Ten discs. That can be solved in (2^n - 1) = 1023 moves. 🤓
View on Reddit #172139

jamcdonald120@reddit

anyone actually tramatized by this failed to actually learn recursion.
View on Reddit #157047

Character-Solid-6392@reddit

Step 1: Learn recursion Step 2: repeat step 1
View on Reddit #171484

pran_anak@reddit

My favorite part of Noveria lmao
View on Reddit #171153

eendomaa@reddit

anyone actually tramatized by this failed to actually learn recursion.
View on Reddit #170740

JustSpaceExperiment@reddit

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.
View on Reddit #156957

1stEleven@reddit

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.
View on Reddit #168301

TerenceFromBelgium@reddit

A [Bogosort](https://en.wikipedia.org/wiki/Bogosort)
View on Reddit #170692

bubbaholy@reddit

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.
View on Reddit #162959

AbhishekSingh26@reddit

Chat gpt new turing test
View on Reddit #169950

notdoreen@reddit

I don't get it.
View on Reddit #165694

value_counts@reddit (OP)

What aspect of this you didn't understand?
View on Reddit #166141

notdoreen@reddit

I don't know what that game is and how it works, or its relationship to programming.
View on Reddit #166754

leva549@reddit

It's a game called "Towers of Hanoi" and it is often as a task for an algorithm in programming/CS courses. It's possible to use a recursion to solve it in a few lines of code, which is not immediately obvious to the uninitiated.
View on Reddit #169894

value_counts@reddit (OP)

Good for you then. It's not worth knowing. People get PTSD from it
View on Reddit #166913

double-happiness@reddit

Somewhere out there there's a video of a kid putting those shaped bricks in a box, and when he struggles with one, he just lifts the lid and puts it in that way. I always thought, that kid would make a good programmer. Logical approach.
View on Reddit #169265

RagnarokAeon@reddit

I feel like programming it for a player would be the easy part: check if top element (disc) of stack\_a (stack you're taking from) is smaller than top element of stack\_b (stack you're attempting to move disc to) I'd only have a nightmares if you were to ask me to create a program to *solve* the Towers of Hanoi.
View on Reddit #169157

yelaex@reddit

Wow, that's was actually my first game that I programmed a long time ago with my dad. It was done according to some book about Visual Basic. Yeah, really long time ago.... Need to call my dad .......
View on Reddit #169081

ukfi@reddit

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.
View on Reddit #168837

value_counts@reddit (OP)

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
View on Reddit #168948

void_juice@reddit

Do whatever move is legal between these rods in this order AB, AC, BC
View on Reddit #155499

mianori@reddit

Hello infinite loops!
View on Reddit #158453

FancyImpact8177@reddit

Hey there! Love your post, definitely never gets old! As for reposts, don't worry about it, always good to share the laughs. It's great to see value_counts in action on this subreddit, keep 'em coming! Happy coding!
View on Reddit #168934

Tarnishedcockpit@reddit

Ah, found the reward designer for warframe
View on Reddit #156898

funnystuff97@reddit

every warframe player's worst nightmare: aabbc on railjack defense, and you need a reward from c
View on Reddit #159423

RyukuGloryBe@reddit

That one mode nobody plays but is the only way to get Harrow. Christ.
View on Reddit #161096

kkjdroid@reddit

They moved him to A a couple months ago.
View on Reddit #168235

SinisterCheese@reddit

Reason I quite warframe. Rotations are always bullshit like aabc or aabbcc. Since basically everything that is timed is 5 mins per round, you need 25 minutes, to get a chance at C reward. And if you have low% C reward, you need to do that run a lot of time. on aabbcc it is 50 fuck-skull-minutes for first C. If you have 1hr of game time a DAY. You can get if you are lucky 2 chances. And with something have 5% drop chance... That is just stupid. I ran Luna Spy to get some moveset thing 200 times, 3/3 no detection. I got it down to being able to do it less than 5 minutes from loading screen to extraction - with Wukong flying fucking everything. The last vault puzzle horseshit wasn't couldn't even be done by randoms 90% of the time - so you had to do it SOLO. So.... Spending closer to 20 hours of my life running Luna Spy... I just fucking gave up and bought the god damn thing with plat... that I paid cash for. I wasn't having fun. And also back then, everyone just ran some bullshit "Click one button with ability bonuses up the arse and everything does". Then take your phone out and play some other game while you are at it.
View on Reddit #161391

Eclaytt@reddit

Stop hating C
View on Reddit #165407

MrPootisPow@reddit

You get to c rotation only to not get the part you need/want
View on Reddit #159616

funnystuff97@reddit

[ash flashbacks]
View on Reddit #159985

MrPootisPow@reddit

Im so old i got dozens of sets of him from the ancient raid Law of Retribution that spawned grineer maniacs like mad
View on Reddit #160302

Ozymandias117@reddit

In the current configuration, doesn’t that heuristic leave all the current circles on B? A -> B is valid, A -> C is valid, then B -> C is valid That doesn’t move the medium sized circles on the B rod, though?
View on Reddit #161640

void_juice@reddit

Between any two rods only one move is legal. If you can’t do A->B then do B->A. It’s just the move between those rods you do in the order not necessarily A->B, A->C, C->B. Often the move will be flipped
View on Reddit #162285

Ozymandias117@reddit

If A-> B and B-> A is legal in the original heuristic, you’ll end up swapping the smallest between A and B infinitely…? Is there some implied rule to AB, AC, BC (with reversals) ?
View on Reddit #162417

umbrellacorgi@reddit

Do A to B, and if you can’t, do B to A Now do A to C, and if you can’t, do C to A Etc…
View on Reddit #165317

Ozymandias117@reddit

If they’re bidirectional, you move A->B then B->A infinitely in this configuration, though
View on Reddit #162336

Important-Ad1871@reddit

This is how you make a perfectly flat surface
View on Reddit #158547

KingCeryn@reddit

Oh yeah? Jokes on them, var ThrowAllRingsOnTheFloor = random.range(0, allthefuckofthem.length), new List <Bullshit> HandsFullOfBullshit, for (i = whocares, allthefuckofthem.length; i++), if (i = bigfuckring && !TryHardTower.Contains (bigfuckring)\]) TryHardTower.Add(bigfuckring). dID iT wOrK???
View on Reddit #168900

Slcolderguy@reddit

I wrote that recursion program on Fortran 77 in 1978
View on Reddit #155934

brucebay@reddit

Geniune question, I have not looked fortran like for 3 decades, did it have user functions at the beginning? All I remember is goto statements.
View on Reddit #157036

ta1852@reddit

Now we have Intel Visual Fortran with multitasking, interoperability, built in GUI libraries that wrap GDI, and you can even put characters in whatever column you want now! Lol I loved finding old F77 code amongst the IVF because the formatting looks insane. Also Notepad++ defaults to the column based formatting for colors which is irritating
View on Reddit #160602

redcalcium@reddit

Might want to look into using Flang as well. Being an LLVM, it open up a lot of new possibilities that Fortran programmers of the past would never imagined in their wildest dream, like compiling a fortran program into webassembly, or transpiling into JavaScript.
View on Reddit #161656

mistahfreeman@reddit

I’m bordering on a senior Java engineer and this conversation both impressed me and pissed me off at the same time.
View on Reddit #168442

Electricengineer@reddit

Save some pussy for the rest of us
View on Reddit #162173

value_counts@reddit (OP)

Thug life
View on Reddit #156000

brando56894@reddit

For I = 2; I+3; I++{stuff}
View on Reddit #168294

1stEleven@reddit

One disk is one step. For two disks, you move the first disk twice, and the second one twice, for three steps. For three disks, you move the top two disks twice, and the third disk once. Now, the pattern is clear. Each next disk doubles the previous amount of steps to solve, and adds one more step on top of that. So that eleven disk game takes 1 3 7 15 31 63 127 255 511 1023 2047 steps to complete. That's not a game, that's torture. For most people, at least.
View on Reddit #168245

RobinsonDickinson@reddit

Unironically helped me understand recursion better. Thanks, freshmen year cpp professor.
View on Reddit #168092

Functional200@reddit

Try to intuitively teach discrete structures (impossible)
View on Reddit #168015

Fadamaka@reddit

Funnily enough I have encountered this first at a comp sci competition for kids. It was on paper so I had to draw how would I solve it step by step.
View on Reddit #167885

Julis_texsture_team@reddit

if thing: if thing2: if thing3: if thing4: if thing5: print("True")
View on Reddit #167750

cyber_blob@reddit

I always wanted to know who or where the Hanoi was. Mofo nearly made me fail my c in freshmen year
View on Reddit #167742

kurisutofujp@reddit

It's a very hanoying game.
View on Reddit #167523

natsuzamaki@reddit

With every circle, the number of moves needed doubles, plus 1. Learn that from a hangout quest in a video game, this is the only joke on this sub I've ever understood
View on Reddit #167513

preetiegal@reddit

Tower of Hanoi 😂
View on Reddit #167041

ShoddyStreet677@reddit

Just yesterday, I learnt to find the number of moves to solve it using recurrence relation.
View on Reddit #166804

Zachosrias@reddit

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, I can just never picture it, what needs to be passed on and where to start, how it should progress.
View on Reddit #164730

value_counts@reddit (OP)

Fibonacci is simple than this bro
View on Reddit #166734

I-wanna-be-tracer282@reddit

This brings back bad memories of me trying to understand Recursion. I sadly still dont understand recursion. I understand the basic concept of stack, recursion but I still dont understand understand it.
View on Reddit #166714

tekktokk@reddit

Towers of hanoi? More like towers of *annoy*, amirite?
View on Reddit #166663

value_counts@reddit (OP)

Yes!
View on Reddit #166666

Brother-Adventurous@reddit

Ask a baby to solve this 👍 Now, Ask a baby to write its recursion recurrence.
View on Reddit #166388

value_counts@reddit (OP)

And you just deprived that kid of their childhood
View on Reddit #166661

Magna8849@reddit

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.
View on Reddit #166457

value_counts@reddit (OP)

Cool bro. We are in same boat
View on Reddit #166640

my-shameless-account@reddit

Easy. They all go in the square hole.
View on Reddit #166610

OSSlayer2153@reddit

It is a repost sadly. Quite frequent one.
View on Reddit #156662

cutebleeder@reddit

It is stuck in a loop with no end.
View on Reddit #166033

bahweepgranah@reddit

Some people started coding it, not knowing what it was
View on Reddit #166534

bahweepgranah@reddit

I once wrote this for the HP 200-LX using the native GUI library.
View on Reddit #166471

Rotten_Tarantula@reddit

Omg... I can never see this innocent childs toy the same way ever again... All I gotta say is thank god for the built in sort function.
View on Reddit #166229

isospeedrix@reddit

I don’t get the bottom picture? A puppy with helicopters in the background?
View on Reddit #165070

rock-n-white-hat@reddit

PTSD
View on Reddit #165997

nryhajlo@reddit

Def a repost, but it never gets old.
View on Reddit #165427

VoliBeast@reddit

Just use some logic gates, some abs, some function and if and then. Easy peasy
View on Reddit #165138

Top_asfuck@reddit

Cool trick to solving this with binary counting. Since the smallest disc is always on top, its the first digit, next biggest disc is the next digit, etc, every time you change a binary digit, that corresponding disc must move.
View on Reddit #165061

Matthew789_17@reddit

I heard someone call it the towers of fucking PTSD
View on Reddit #165012

FlyByPC@reddit

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.)
View on Reddit #164819

nametakenfuck@reddit

Not sure what the rules are
View on Reddit #164266

machen2307@reddit

All the rings start off in a stack on either side, so we'll say the left. The goal is to get all the rings onto the far right pin, but you can only move one ring at a time, and you can't stack bigger rings on top of smaller rings. It's called Tower of Hanoi and there are different variations on how to play it, but that's the most basic concept if I'm not mistaken. It's certainly the easiest way to explain how the game works anyway.
View on Reddit #164616

nametakenfuck@reddit

Oh the part that makes it complicated is the one with the size k
View on Reddit #164668

Shorthawk@reddit

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)
View on Reddit #164571

GeePedicy@reddit

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.
View on Reddit #154120

pugs2424@reddit

[you are correct](https://www.reddit.com/r/ProgrammerHumor/comments/zb76ge/huhhits_easymade_for_kids/)
View on Reddit #164526

Featureless_Bug@reddit

Solid piece of analysis for someone who doesn't care about reposts
View on Reddit #155049

qjornt@reddit

Tbf they said "I don't care as much as I used to". Which means they still care at least some amount.
View on Reddit #159216

BestAhead@reddit

His amount of care at the present could be equal to zero.
View on Reddit #163054

GeePedicy@reddit

I mean, I used to be a lot more critical and judgemental, so it's not all out of my system. I get the irony, but now I'm way more annoyed by karma farming *bots*. OP seems like they wanted to share a thing they liked, but these bots? God help if I'd understand it. Imagine caring so much about virtual pointless points you create a bot for it, that doesn't even use your own original content.
View on Reddit #157386

hreloaded@reddit

Care anymore**
View on Reddit #156207

RepostSleuthBot@reddit

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](https://www.reddit.com/message/compose/?to=RepostSleuthBot&subject=False%20Negative&message={"post_id": "121qs09", "meme_template": 298230}) ]* [View Search On repostsleuth.com](https://www.repostsleuth.com/search?postId=121qs09&sameSub=false&filterOnlyOlder=true&memeFilter=true&filterDeadMatches=false&targetImageMatch=100&targetImageMemeMatch=75) --- **Scope:** Reddit | **Meme Filter:** True | **Target:** 75% | **Check Title:** False | **Max Age:** Unlimited | **Searched Images:** 383,839,545 | **Search Time:** 0.72267s
View on Reddit #154132

ByterBit@reddit

Can someone write a bot that uses GPT-4's image analysis to explain the joke?
View on Reddit #157704

OSSlayer2153@reddit

I swear ive seen this here 3 or 4 different times
View on Reddit #156680

PacoTaco321@reddit

1. Google the Computerphile video on this problem 2. Copy paste the code 3. Celebrate programming prowess
View on Reddit #164358

WeAreBeyondFucked@reddit

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)
View on Reddit #164115

Muted_Resist_8622@reddit

Damnit, lol that was me this semester in college doing discrete mathematics.
View on Reddit #161638

YerpyMoose@reddit

gimme some of those non-homogeneous nonlinear recursive relations and a sprinkling of cataln numbers with a side of boolean matrices, please
View on Reddit #162736

Muted_Resist_8622@reddit

Best I can do is hand writing out multiplicities of Pascal’s triangle by only using symmetries of lattices haha
View on Reddit #163704

Dzagoev-0705@reddit

OK, I don't get it.
View on Reddit #163692

vivekkhera@reddit

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.
View on Reddit #163513

modulusshift@reddit

Wait why is this hard? Seems pretty intuitive to me? Maybe I’ll try coding up a solver?
View on Reddit #162685

Nyugen1990@reddit

Not "difficult" in itself i think, However it was the introduction to recursive algorithm at my university, which was quite the rabbit hole for me at least. Really blew my mind when I finally learned to solve it with less then 10 lines which was the task.
View on Reddit #163193

El_Dre@reddit

It’s a combination of being not *quite* as simple as it looks, and being most CS students’ first run-in with designing their own algorithm (this is a first semester, intro to programming assignment).
View on Reddit #163182

KirisuMongolianSpot@reddit

People who've played Bioware games: :traumatized:
View on Reddit #162894

YamStallion@reddit

Programmer: *repeatedly puts the loops on at random with their eyes closed while making beep Boop sounds*
View on Reddit #162859

Fuzzy-Help-8835@reddit

Wouldn’t this pic be 1023 moves to solve?? I’m out, it’s Diablo 4 beta weekend. 🤷‍♂️
View on Reddit #162780

alsico@reddit

We have a lifo right here
View on Reddit #162719

Justalittleratt@reddit

I don't get it. Btw I'm not a programmer.
View on Reddit #161935

Fuzzy-Help-8835@reddit

Towers of Hanoi.
View on Reddit #162690

_Reyne@reddit

I have an "adult" version of this. I had no idea they made children's toys out of it. Mine has 8 disks and it's honestly so fucking toxic. Even if you do it right it takes ages to solve just because of how many moves you have to do. It took me probably 4 hours the first time I did it with no instruction or anything.
View on Reddit #162657

Script_Mak3r@reddit

>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.
View on Reddit #162612

Conaz9847@reddit

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.
View on Reddit #162416

reallygaydar@reddit

*rocks back in forth crying due to radix sort*
View on Reddit #162337

AverageLinuxUsr@reddit

fucking hanoi recursion i SWEAR
View on Reddit #162335

manofredearth@reddit

Purple two to one Red two to one Yellow two to three Blue one to two Green one to three Blue one to three
View on Reddit #162289

Zealousideal-Debt884@reddit

erm
View on Reddit #162287

EducationalNose7764@reddit

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.
View on Reddit #162044

dasbodmeister@reddit

Hanoi ... Vietnam flashback. ![gif](emote|free_emotes_pack|facepalm)
View on Reddit #156044

Aethermol@reddit

I wonder how many were *fortunate* enough to catch this
View on Reddit #161873

MrKristijan@reddit

I don't understand it and now I'm too afraid to ask
View on Reddit #161818

you90000@reddit

I rather implement a binary search tree from scratch again
View on Reddit #161814

RedLion_the_1st@reddit

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.
View on Reddit #161746

JayCroghan@reddit

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.
View on Reddit #161723

FuckKeanu@reddit

Wait a) who says this is a game for kids and b) who says this is hard?
View on Reddit #161651

SanianCreations@reddit

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: 1. 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. 2. There is only one possible move that doesn't move the smallest piece. Do that move. 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
View on Reddit #161648

mechanical_marten@reddit

Ternary counting in 128base3 steps!
View on Reddit #161551

JustAGuyWhoGuitars@reddit

I don't get any PTSD from this; I look back on this fondly. Learning how to do recursion and dynamic programming was awesome.
View on Reddit #161542

regal-me@reddit

Just splice the three arrays together
View on Reddit #161490

AtroxMavenia@reddit

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.
View on Reddit #161476

That-Row-3038@reddit

I feel sorry for the poor people of Hanoi, everytime they build a tower someone must come along and reshuffle it
View on Reddit #155058

chessdotbmp@reddit

Maybe in the '70s some unfortunate son would show up and rearrange things, but it's not so bad nowadays.
View on Reddit #161412

coladict@reddit

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.
View on Reddit #161393

grayzee60@reddit

Recursion😳😳
View on Reddit #161386

00tool@reddit

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.
View on Reddit #161162

Braza117@reddit

Mass effect 1 players
View on Reddit #161126

SBG_Mujtaba@reddit

Seriously ? Tower of Hanoi….what’s so hard about it ?
View on Reddit #154696

HoroAI@reddit

VS 101 is just a slog.
View on Reddit #161084

AndianMoon@reddit

ME1 flashbacks
View on Reddit #160962

edwardrha@reddit

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 machine learning tools have become extremely easy to use...
View on Reddit #157351

multikore@reddit

could be either, could be neither... could be both
View on Reddit #160929

JJJSchmidt_etAl@reddit

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.
View on Reddit #160923

Lizlodude@reddit

*dumps all the rings on the ground* there are no rules here!
View on Reddit #160831

UltraBatmanTheSeven@reddit

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.
View on Reddit #160822

Heroshrine@reddit

Can someone link me to this exercise? I was never directed to do this and I’d like to try it
View on Reddit #160739

NotTheOnlyGamer@reddit

Relatedly to programmers, Myst players remember the same feeling.
View on Reddit #160684

GuiGeeKang@reddit

It's a good mathematical exercise that can be used to solved a lot of real-world problems.
View on Reddit #155587

shadedreality@reddit

I'm struggling to think of an example? Prioritized error handling? idk
View on Reddit #160385

Jealous-Ninja5463@reddit

Backups to separate media is one that comes to mind
View on Reddit #160648

Reuarlb@reddit

Shh don't let the kids know learning math actually helps
View on Reddit #158795

PhantomTissue@reddit

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.
View on Reddit #160353

Madmonkeman@reddit

Wait, what exactly is the goal of the puzzle?
View on Reddit #160572

PhantomTissue@reddit

It’s call the tower of Hanoi, you have to move all the rings from the left tower to the right, but you can only move one ring at a time, and a larger ring can never be placed on top of a smaller ring.
View on Reddit #160627

A_Cookie_Lid@reddit

Anyone else remember playing this on Poptropica? Or am I too young lol.
View on Reddit #160546

pagerunner-j@reddit

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.
View on Reddit #160522

Awanderinglolplayer@reddit

With the number of rings there this is a good way to keep a kid busy
View on Reddit #160441

C_Khoga@reddit

Genshin impact fans 😍
View on Reddit #160408

ki4clz@reddit

https://en.m.wikipedia.org/wiki/Tower_of_Hanoi
View on Reddit #160386

SpaceshipEarth10@reddit

Hahaha…oh wow. That brought back some memories frfr.
View on Reddit #160322

AnsonKindred@reddit

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.
View on Reddit #160320

Libra_Maelstrom@reddit

What- i- did I not learn this? What is this? Is this supposed to be a stack metaphor or a queue or something
View on Reddit #157357

drunkdoor@reddit

3 stacks and 10 objects each with a different radius. You can only stack smaller objects into larger ones. Now form one tower.
View on Reddit #158348

Libra_Maelstrom@reddit

Oh…. You can only Move one at a time, huh? I see..
View on Reddit #159180

drunkdoor@reddit

Yep
View on Reddit #160311

Agent_Seed@reddit

I had to do this to get my adhd diagnosis
View on Reddit #160288

Petah_Futterman44@reddit

I did this as part of my test for ADHD and failed it so hard lol.
View on Reddit #160178

philipes@reddit

The first chapter of Concrete Mathematics still hunts me to this day.
View on Reddit #160163

S-U_2@reddit

Come on it's only 7 steps.......
View on Reddit #159859

queiss_@reddit

This shit still confuses me
View on Reddit #159709

Comrade__Baz@reddit

This is the reason I can't finish Turing Complete
View on Reddit #159676

Adrunkopossem@reddit

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
View on Reddit #159657

QtQMLer@reddit

My Assembly class final was implementing Towers of Hanoi with a full GUI. It was my Vietnam.
View on Reddit #159541

MoistExcellence@reddit

In order to understand recursion, you must first understand recursion.
View on Reddit #159397

globocide@reddit

Since you asked: If you didn't create it then it's a repost.
View on Reddit #159343

save_the_its_pronoun@reddit

>>ToH: Tower of Hanoi
View on Reddit #159281

Tashre@reddit

Easily solved with the right CSS.
View on Reddit #159213

mosquitoLad@reddit

I've not implemented toh; is there a reason it is treated as difficult? Can it not be handled well with linked lists?
View on Reddit #157734

Booke@reddit

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.
View on Reddit #159108

sethpen@reddit

I remember playing this in the original game Black & White. I never knew it was a programmers nightmare.
View on Reddit #159027

sheriffjt@reddit

(2^n) - 1 still etched in my brain
View on Reddit #158949

mbxz7LWB@reddit

I don't get it. Make three arrays. Put each pole and it's rings in an array. Sort each array by highest to lowest. Display results.
View on Reddit #158850

cheezballs@reddit

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
View on Reddit #158797

Lanbaz@reddit

LC hard for sure 😆
View on Reddit #154273

LuckyCharmsNSoyMilk@reddit

In fairness, fuck TOH.
View on Reddit #158796

AspiringTS@reddit

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...
View on Reddit #158790

cybercuzco@reddit

It’s not a repost.
View on Reddit #158509

FofoPofo01@reddit

To be fair the game is simple. The rules are simple. To play it is simple. But especially, when you’re leaning to program, basically encapsulating anything into algorithm is complicated. Only until you start to program do you gain any appreciation for data structures and algorithms in everyday life. Like elevators for example. Holy cow are they ever complex. This is why I sympathize with the challenges and the costs that startups face just to keep a very basic service up and running.
View on Reddit #158484

bunkscudda@reddit

Not a programmer, but IT. I learned this because it creates the perfect data backup rotation.
View on Reddit #158400

Phlm_br@reddit

This unlocked a memory for me. I got this as a gift a long while ago. It's kinda fun
View on Reddit #158379

No_Solid2349@reddit

Hahahaha. I got that reference !!!😅
View on Reddit #158263

DigitalSteven1@reddit

I think it's a very good representation of the stack.
View on Reddit #158158

drabid@reddit

BioWare devs: How about we put HoT in SPAAAACE!
View on Reddit #158143

indianbeam@reddit

tower of Hanoi
View on Reddit #158130

SawSaw5@reddit

Dog: What is your favorite sort algorithm?
View on Reddit #158090

tiagohbalves@reddit

It's just move the piece to left.
View on Reddit #157952

Cyberdragon1000@reddit

Well I don't know Hannoi but I do know their towers😂
View on Reddit #157899

PTSDaway@reddit

Bring out the noteblock and start scribbling flowcharts
View on Reddit #157706

dogol__@reddit

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
View on Reddit #157661

UndefeatedWombat@reddit

Tower of annoy
View on Reddit #157587

romchik1987@reddit

This hits so hard. I'm currently solving a TOH problem.
View on Reddit #157188

LoonyMessiah@reddit

Recursion go brrrr...
View on Reddit #157177

trimeta@reddit

Once you understand that solving the Towers of Hanoi is basically just "counting in binary," you'll never need a recursive solution again.
View on Reddit #157163

PsLJdogg@reddit

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](https://en.wikipedia.org/wiki/The_Secret_Island_of_Dr._Quandary). Even just seeing this puzzle gives me PTSD.
View on Reddit #157098

Equivalent-Map-8772@reddit

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.
View on Reddit #157094

esberat@reddit

Hard times.
View on Reddit #156996

yaMomsChestHair@reddit

It does actually get old when its posted all the time.
View on Reddit #156921

totalsoupsloud@reddit

2 to the disk, ..... 2 to the disk, ...... 2 to the disk
View on Reddit #156414

SlowWhiteFox@reddit

In a nutshell: solve_problem(problem): simpler_problem = take_one_step_towards_goal(problem) solve_problem(simpler_problem)
View on Reddit #156139

monasfe@reddit

Codeforces perf
View on Reddit #156024

e_smith338@reddit

I’ve never used this in anything programming related, but remember doing this plenty of times as a kid in school.
View on Reddit #155998

thepr0digalsOn@reddit

Also.. "Hanoi" is supposed to give you war flashbacks
View on Reddit #155742

kvakerok@reddit

You just had give me flashbacks.
View on Reddit #155706

HammerTh_1701@reddit

I beat a robot at Towers of Hanoi at an expo. It was in machine-human-cooperation slow-mode...
View on Reddit #155495

SomeRandoLameo@reddit

No no no no nO NO NO NO PLEASE NOOOO
View on Reddit #155471

mgisb003@reddit

LIFO
View on Reddit #154761

hrfuckingsucks@reddit

This is too accurate an assessment of my abilities. I demand it be taken down.
View on Reddit #154381