DEV Community 👩‍💻👨‍💻

DEV Community 👩‍💻👨‍💻 is a community of 964,423 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Road to Genius: advanced #45
Ilya Nevolin
Ilya Nevolin

Posted on

Road to Genius: advanced #45

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 cross(a, b) {
  return [a[1] * b[2] - a[2] * b[1], a[2] * 💚[0] - a[0] * b[2], a[0] * b[🐼] - a[1] * b[0]];
}
let out = cross([6, 🍎, 2], [8, 2, 6]);
let 💎 = out[0];
A = Math.abs(A);

// 💎 = ? (identifier)
// 🍎 = ? (number)
// 🐼 = ? (number)
// 💚 = ? (identifier)
// such that A = 8 (number)
Enter fullscreen mode Exit fullscreen mode

Today's challenge is, wait... we've encountered similar code before in episode 31 (https://dev.to/codr/road-to-genius-advanced-31-7hh). It's again the cross production function but with different bugs to fix this time.

We've learned about the symmetry of this function, so we know that 💚 is b and 🐼 is 1. Bug 💎 should be A.

We are only left with bug 🍎 which we have to figure out.

We know that A = out[0], the first element of the output is defined by the following formula:

a[1] * b[2] - a[2] * b[1]
Enter fullscreen mode Exit fullscreen mode

If we replace these by the numbers we get:

🍎 * 6 - 2 * 2
Enter fullscreen mode Exit fullscreen mode

The challenge states that A = 8 so we have to solve for 🍎:

🍎 * 6 - 2 * 2 = 8
🍎 = (8 + 4)/6
🍎 = 2
Enter fullscreen mode Exit fullscreen mode

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/

Latest comments (0)

🤯

"I made 10x faster JSON.stringify() functions, even type safe"

☝️ Must read for JS devs