## DEV Community 👩‍💻👨‍💻 is a community of 930,237 amazing developers

We're a place where coders share, stay up-to-date and grow their careers. # Road to Genius - Python Series level 1

In this post I will solve and explain several Python code challenges from Codr's Ranked mode. The goal is to reach the Genius level, so join me at Codr!

Instead of posting one challenge per day, I will instead post several in one. The first code asks us to fix a bug, which should be a number such that the answer `R = 30`. The answer is pretty simple, the `people` variable is a list of objects with name and age. The bug is Ana's age, with the if-condition below requires Ana's age, since R should be 30, we know that 30 is her age.  Here we have two bugs, the first one is R's value, and if you look at the code you see that R is being used as a boolean. Since R should eventually be False, then R should be initialized as False, unless the if-condition is true, which it shouldn't as long as the rocket isn't equal to 3.  The same algorithm as before, this time the first bug should be the arr variable. The second bug's value doesn't matter because the if-condition won't execute anyway.  A very simple one right here. We need to fix the operator on the second line, which is highly like to be an assignment `=`.  A slightly more complicated algorithm here. We need to fix a bug in the function nonzero as well as one of its inputs. The first bug is a variable name which should be `j`, since it is used below and should be declared.

To fix the red apple, we need to figure out what the algo does. So given an input list of 4 numbers and `i=3`, it should return 4. Here's some pseudo code of that function:

``````j = i+1 = 3+1 = 4
while(j < 4 and ...)  --> j is not less than 4, so we can skip the while loop
return j (=4)
``````

The values inside the input array are irrelevant because the while-loop isn't executed, so the red apple can by anything. As easy as that, we made it to the 2nd "Smart" level. If you enjoyed this post, make sure to join Codr, like and follow <3!