DEV Community

Cover image for Road to Genius: genius #69
Ilya Nevolin
Ilya Nevolin

Posted on

Road to Genius: genius #69

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.

function TZ(n) {
  let N = 0;
  while (n >= 5) {
    N += ๐Ÿ˜ˆ.floor(๐ŸŽ / ๐Ÿ’ง);
    n = ๐Ÿ’ฐ.floor(n / 5);
  }
  return N;
}
;
let A = TZ(TZ(TZ(12200)));

// ๐Ÿ’ฐ = ? (identifier)
// ๐Ÿ˜ˆ = ? (identifier)
// ๐ŸŽ = ? (identifier)
// ๐Ÿ’ง = ? (number)
// such that A = 188 (number)
Enter fullscreen mode Exit fullscreen mode

Here's an interesting challenge, we have to fix 4 bugs in a pretty short code base.

All four bugs appear on two sequential lines. We immediately see that ๐Ÿ˜ˆ and ๐Ÿ’ฐ should be Math because they use the common floor function. The final two bugs ๐ŸŽ and ๐Ÿ’ง are tricky to find. However, if we look at the possible answers for ๐Ÿ’ง (number) it shows 12200, 5 and 0; dividing by 12200 and 0 makes little sense, but dividing by 5 is also done on the next line of code. Since ๐Ÿ’ง is likely to be 5, then ๐ŸŽ could be n for the same reason:

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. Get started and become a certified Codr today at https://nevolin.be/codr/

Top comments (0)