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.
In this post I will cover two challenges, because the first one is pretty short ;)
In the first challenge, we are given an array which we fill with numbers using a for-loop. At the end we compute the value for R
by checking if π° includes the number 6. The task is to find what identifier π° is. But as I already spoiled, it's the array which we filled up. There, done!
The second challenge is only slightly more complicated than the first one. There's a bit more code, but still peanuts to solve. The quest is to fix two bugs (π and πΌ), such that R = 30
. The first several lines of code create an array people
which consists of 4 objects. If you look at the members of these objects they are name
and age
, looks like the object is representing a person. Then we see there's a for-loop which iterates over all objects in the array, this line contains a first bug π, we can safely assume that π should be the variable person
because it is used below. Next, the if-condition checks if the person's name equals ana
, if that is true, R
gets the value of that person's age. If we look back at our array of people, the person named ana
has age 30, as expected.
But hey, what about πΌ? In this scenario it's irrelevant what πΌ should be, just make sure it's not ana
to ensure that R=30
is true.
If you feel inspired and motivated to upgrade your coding + debugging skills, join me on the Road to Genius at https://nevolin.be/codr/
Oldest comments (0)