DEV Community

alex brady
alex brady

Posted on

1

Can you spot the algorithmic error?

Buggy Code

This algorithm has a bug in it.

Alt Text

(Spoiler Alert: Solution below)

This is the same pseudocode with the bug removed
Alt Text

Did I miss any bugs?

Top comments (2)

Collapse
 
moopet profile image
Ben Sinclair

Did you miss any bugs? Yes, the question count is undefined. For it to work in your code it needs to start at zero, otherwise the length of the game is indeterminate and possibly infinite :)

Collapse
 
iamalexbrady profile image
alex brady

I actually just fixed this in the actual blog post yesterday. Good eye!

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay