DEV Community

alex brady
alex brady

Posted on

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!