On Coderbyte we offer over 70 easy difficulty programming language code challenges that are perfect for beginners who are learning to code and need some way to practice. We looked at the stats for our easy challenges (excluding the medium and hard questions) and found the ones where users struggled with the most to achieve a perfect score. We ended up narrowing down all the easy challenges to find the 5 hardest ones listed in the "easy" section - whereby easy we mean challenges that should be solvable somewhere between 15-25 minutes by a beginner coder.
Hardest Beginner Challenges
The 5 hardest "easy" challenges are listed below:
Question Marks: Requires looping through a string and checking if certain conditions are met.
Vowel Square: Requires finding a 2x2 square of vowels in a larger matrix.
Scale Balancing: Requires looping through an array of weights to determine if a scale can be perfectly balanced.
Correct Path: Requires traversing through a partially finished path in an NxN matrix and finishing the path.
Closest Enemy II: Requires checking the distance between certain points in a NxM matrix.
Out of these, the challenge where users struggled most to get a perfect score and spent the longest time solving is Question Marks.
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).
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.
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.
Below is a very concise and elegant solution written in Python by the #3 ranked user on Coderbyte, Qlogin.
qnum = 0
dig = 0
has_10 = False
for ch in s:
if int(ch) + dig == 10:
if qnum != 3:
has_10 = True
dig = int(ch)
qnum = 0
elif ch == '?':
qnum += 1
return 'true' if has_10 else 'false'
There is also a clever regex solution that a user on Coderbyte implemented in Java to solve the challenge: