Home‎ > ‎

Hardest Code Challenge for Beginners

https://medium.com/coderbyte/the-5-hardest-code-challenges-for-beginners-e410da4474b

Challenge Description

Take an input string parameter and determine if exactly 3 question marks exist between every pair of numbers that add up to 10. If so, return true, otherwise return false. Some examples test cases are below:

"arrb6???4xxbl5???eee5" => true
"acc?7??sss?3rr1??????5" => true
"5??aaaaaaaaaaaaaaaaaaa?5?5" => false
"9???1???9???1???9" => true
"aa6?9" => false

Before reading further, try and think of how you would solve this challenge (you can even write down some steps in pseudocode, or better yet you can write a solution on Coderbyte).

Analysis

This challenge requires several layers of logic to get right, which is why it can be difficult to come up with a solution at first. It requires looping through the string and maintaining the position of every pair of numbers that add up to 10. If you do find two numbers that add up to 10, then you will need to determine if exactly 3 specific characters exist somewhere between these two indices.

  • 68% of users who submitted a solution in JavaScript didn’t get a perfect score.
  • 35% of users who submitted a solution in Ruby didn’t get a perfect score.
  • The average number of lines for a solution is 15–29.


Other Challenges...

https://edabit.com/challenges/python3




Comments