Raj has solved the puzzle below:
24 -> 1
1264 -> 2
9899 -> 5
349 -> x
Raj determined that the puzzle can be solved by counting the number of holes in the digits of a number. e.g. 1,2,3,5,7 have no holes, 0, 4, 6,
9 have 1 hole each, and 8 has 2 holes. 2 is therefore the value of x to the last line.
Excited by this discovery, Raj now wants to solve this puzzle using a computer program. You have to write a function whose signature is
solvePuzzle(int num) where num is the input integer, and the return value is the number of holes in num.
Constraints:
1 ≤ num ≤ 10
There will be no leading zeroes.
Sample Input #0:
630
Sample Output #0:
2
Explanation #0:
6 and 0 have one hole each
Sample Input #01:
1288
Sample Output #01:
4
Explanation #01:
Both 8's contain 2 holes each.
What I have tried:
echo rand() . "\n";
echo rand() . "\n";
echo rand(5, 15);
?>