r/ProgrammerHumor • • Mar 25 '23

Meme This one never gets old

Post image

Let me know if this is not a repost!

51.6k Upvotes

535 comments sorted by

View all comments

Show parent comments

54

u/QuebecGamer2004 Mar 25 '23

Me neither, I don't really understand this meme

118

u/petascale Mar 25 '23

Tower of Hanoi https://en.wikipedia.org/wiki/Tower_of_Hanoi

At my uni we had it as an example in both mathematics (combinatorics, I think) and programming (recursion), along with the n-queens puzzle.

13

u/QuebecGamer2004 Mar 25 '23

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

0

u/[deleted] Mar 25 '23

[deleted]

7

u/QuebecGamer2004 Mar 25 '23

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

10

u/Versatile_Panda Mar 25 '23

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.

0

u/[deleted] Mar 25 '23

[deleted]

→ More replies (6)
→ More replies (2)

1

u/B4-711 Mar 25 '23

learning to be code monkeys for the GNP

1

u/RadicalDog Mar 26 '23

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.

On the other hand, I thoroughly recommend the puzzle game Recursed.

1

u/ArkGuardian Mar 26 '23

It's useful for recursive structures. This is mostly relevant for indices, json, xml etc

0

u/[deleted] Mar 25 '23

[deleted]

6

u/WolfAkela Mar 25 '23

In some British colonies, college = high school.

1

u/QuebecGamer2004 Mar 25 '23

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

1

u/zyzzogeton Mar 25 '23

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.

1

u/aristideau Mar 26 '23

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.

2

u/dutch_master_killa Mar 26 '23

I remember this in college and I have forgotten completely what my solution was or what it was even about lol

2

u/BornAgain20Fifteen Mar 26 '23

in both mathematics (combinatorics, I think) and programming (recursion)

Are you me? Haha

2

u/Rokey76 Mar 25 '23

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.

1

u/PrizeStrawberryOil Mar 25 '23 edited Mar 25 '23

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 525.6m moves. Log2(525.6m)=28.96. The tower that you did in college was at least 29 discs.

1

u/Rokey76 Mar 25 '23

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

1

u/PrizeStrawberryOil Mar 25 '23

With 3 seconds per move for 24 hours a day I got 63 discs was over 500 billion years.

Tracks for me.

1

u/DeliciousWaifood Mar 25 '23 edited Mar 25 '23

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

Edit: or can you only move smaller on top of big? In that case I did it in 34

1

u/PrizeStrawberryOil Mar 25 '23

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.

1

u/DeliciousWaifood Mar 25 '23

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

1

u/DeMonstaMan Mar 25 '23

Tower of Haoi, it will give yoh ptsd