Road to Genius: genius #69

codr

Ilya Nevolin

Posted on August 7, 2020

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/

💖 💪 🙅 🚩
codr
Ilya Nevolin

Posted on August 7, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Road to Genius: genius #69
javascript Road to Genius: genius #69

August 7, 2020

Road to Genius: superior #66
javascript Road to Genius: superior #66

July 31, 2020

Road to Genius: superior #59
javascript Road to Genius: superior #59

July 24, 2020

Road to Genius: superior #58
javascript Road to Genius: superior #58

July 23, 2020