DEV Community

Cover image for Road to Genius: smart #24
Ilya Nevolin
Ilya Nevolin

Posted on

Road to Genius: smart #24

Each day I solve several coding 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, and you will learn a ton of new and interesting things as you go.

coding challenge

In this challenge we have to fix four bugs, it's an easy challenge but does require some attention.

The first three lines initialize variables A, B and C, the value for A is unknown 😈. The 4th line declares R using the equation:
(💚 + B + 💎) / 3;
This line contains the bugs 💚 and 💎, these are most likely going to be A and C respectively (B in the middle spoils it). The formula appears to be computing the average value of three variables.

Finally we have the buggy line:
R = 🚀.floor(R);
The commonly used function floor reveals that 🚀 must be JavaScript's Math object.

To find our remaining bug 😈, we must reverse engineer R, which we know should equal to 4 (given). This can also be written as:
4 = (A+1+5)/3 with A being the unknown 😈.
After rewriting this equation we find that A = (4*3)-1-5 = 6. But 6 is not an available answer to select, so we must use another value for 😈. Keep in mind that the value R is being floor-rounded on the last line, so basically 😈 can be any value as long R = 4. The acceptable answers are 7 and 8, because:
(7+1+5)/3 = 4.333 and (8+1+5)/3 = 4.666

coding challenge answer

By solving these challenges you train yourself to be a better programmer. You'll learn newer and better ways of analyzing, debugging and improving code. As a result you'll be more productive and valuable in business. Join me on the Road to Genius and upgrade your programming skills, at

Top comments (0)