54 points

I like recursive functions tho

permalink
report
reply
37 points

Yet I have not met a CS grad without a trauma.

permalink
report
parent
reply
14 points

I’ve had 7 traumas this week and counting *rocks back and forth*

permalink
report
parent
reply
12 points

I have a production bug… it only happens on Saturdays ever our ops folks have no idea - this can be replicated on a test server that gets no traffic.

Saturday why!

permalink
report
parent
reply
5 points

If we reject the theory that it could be someone’s elaborate revenge, Saturday may be the first day of the week that may become workday or non-workday because of incorrect assumption about the first day of the week. If everywhere but one place in your software the day numeration is correct it would be a hard bug to spot.

Also, if it is in Java, I vaguely remember there being a lot of ways to express weekday, so a lot of ways to shoot off your foot (solely on Saturday)

permalink
report
parent
reply
3 points
*

Please tell me it doesn’t still happen when you emulate a different day of the week. Or is that non-trivial to even do because of technical debt? Either way, RIP weekends.

permalink
report
parent
reply
-1 points

I’ve always hated recursion. It’s always seemed like a cutesy programming trick that’s not reliable in all conditions.

You could blow the stack in an edge case that you didn’t think of. So it should never be a standard pattern. It’s only good if you need to rewrite something for optimization and recursion is appropriate. But in many cases recursion is slower.

“Look at what I can do in 5 lines of code!” is for programming contests, not for anything important.

permalink
report
parent
reply
39 points

Nah Hanoi was easy stuff, first year. Definitely more traumatizing practice problems.

permalink
report
reply
12 points

Hanoi […] practice problems.

Like you come to the exam and there’s a 64 piece Tower of Hanoi you need to solve manually to pass the exam

permalink
report
parent
reply
3 points

Assuming 1 second per swap, a 64 disk tower of hanoi would take 585 billion years to solve - it has 2^64 -1 swaps.

permalink
report
parent
reply
2 points

And that makes It good enough for an exam

permalink
report
parent
reply
2 points

Calm down, satan

permalink
report
parent
reply
7 points

Yea, get back to me when you get to parallel programming.

permalink
report
parent
reply
3 points

Writing kernels for parallel execution with OPENCL gives me flashbacks every time I remember them

permalink
report
parent
reply
3 points

Or even just try to understand pthreads.

permalink
report
parent
reply
2 points

You’re doing it again

permalink
report
parent
reply
2 points

Tis’ not hard, just add some sleeps to make sure other thread reads data before it is destroyed 🌚

permalink
report
parent
reply
31 points

I didn’t have to program this, thankfully. The code was used as an example of recursion but the explanation was lacking so I ended up writing out each frame by end until I understood it. Took a few pages and a couple of hours.

I am grateful that I learned what I did going through it but I’d rather not do it again.

permalink
report
reply
24 points

Fuck all programming puzzles. I refuse them.

True hommies hate them too.

permalink
report
reply
19 points

Replacing “Programmers:” with “Program:” is more accurate.

spoiler

Tower of Hanoi is actually easy to write program for. Executing it on the other hand…

permalink
report
reply
10 points

It’d be a trick if you didn’t already know the answer. Or at least, it would be for me. It’s also hard to actually visualise.

permalink
report
parent
reply
7 points

I didn’t know the answer either, but usually you can compose solution from solutions of smaller problems.

solution(0): There are no disks. Nothing to do. solution(n): Let’s see if I can use solution(n-1) here. I’ll use solution(n-1) to move all but last disk A->B, just need to rename the pins. Then move the largest disk A->C. Then use solution(n-1) to move disks B->C by renaming the pins. There we go, we have a stack based solution running in exponential time.

It’s one of the easiest problem in algorithm design, but running the solution by hand would give you a PTSD.

permalink
report
parent
reply
1 point
*

Good for you. I think I’d figure it out eventually, but it would certainly take me a while.

I’d probably be trying a number of approaches, including the recursive one. Renaming pegs is a critical piece that you’d have to realise you can do, and you can’t be sure you have a correct inductive solution unless you actually walk through the first few solutions from the base instance.

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

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

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 3.5K

    Monthly active users

  • 1K

    Posts

  • 38K

    Comments