DEV Community

Cover image for Road to Genius: beginner #13
Ilya Nevolin
Ilya Nevolin

Posted on

Road to Genius: beginner #13

Each day I solve several challenges and puzzles from Codr's ranked mode. The goal is to reach genius rank, along the way I explain how I solve them. You do not need any programming background to get started, but you will learn a ton of new and interesting things as you go.

programming challenge

We are approaching the upgrade from "beginner" to "smart" rank, just a few more problems left. I am excited about this new challenge. We have seen this code before in a slightly different version. We need to fix two bugs 🐼 and 😈. The first one appears to be an initial value for variable N, which is used as a condition in the for-loop. Inside the loop we are filling the array with numbers under the condition that i % 3 == 0. This means that if we divide i by 3, the remainder should be zero, in other words the division should result in a whole number. Whole number divisions for 3 are: 0, 3, 6, 9, ... The challenge states at the end that R = 5, since R hasn't been declared before then 😈 is most likely going to be R. If we take a peek at the possible answers for 🐼, we see 0, 5 and 13. The first two are incorrect because those conditions will not generate enough numbers for the array to contain 5 items (indicated by R). The only valid answer is 13 and we can prove it: 0, 3, 6, 9 and 12 are the five numbers that are divisible by 3 (whose remainder is 0).

programming challenge answer


If you feel inspired and motivated to upgrade your coding + debugging skills, join me on the Road to Genius at https://nevolin.be/codr/

Top comments (0)