Challenge
Create a function that takes an string as a parameter. (Easy as far)
This string will contain
- Single digit numbers
- Letters from the alphabet
- Question marks (Of course)
Your function will check if there are exactly 3 question marks
between every pair of two numbers that add up to 10 or more. If so, then your function should return truthy
, otherwise it should return falsey
.
If there are not any two numbers that add up to 10 or more in the string, your function should return false.
Rules
- Input must be a string
- Output must be
truthy
orfalsey
value - If string contains only one number or none return
falsey
- If string contains odd amount of single digits, ignore the last one (left to right)
Example
Given: "arrb6???4xxbl5???eee5"
Your function must output true
because
there are exactly 3 question marks
between 6
and 4
, and 3 question marks
between 5
and 5
at the end of the string
Given: "a4sd???9dst8?3r"
Your function must output false
because there is just a single question mark
between 8
and 3
Test Cases
Input: "aa6?9"
Output: false
Input: "acc?7??sss?3rr1??????5"
Output: true
Input: "sdty5???xcd8s3"
Output: true
Input: "sthfer5dfs"
Output: false
Update (Some clarification points)
- Once you use a number to pair with other, you can not use it again.
- You only can pair consecutive numbers (left to right). Example
"as4f???6sda3?3d"
the pairs are4-6
and3-3
This is code-golf, so the shortest answer in bytes win.