Submit | All submissions | Best solutions | Back to list |
DIGHOLES - Digit Holes |
Elly's evil teacher assistant Torb has given her the following puzzle: 42 → 1, 1337 → 0, 669 → 3, 1882 → 4, 688 → 5, 12345 → 1, 67890 → 5, 123 → 0, 456 → 2, 789 → 3. Given this information, 45678 → ?
Thanks to her fast thinking and problem-solving intuition she has found the solution: Google. The answer turned out to be the total number of "holes" in the digits of the number's decimal representation (with no extra leading zeroes). We can see that the digits 1, 2, 3, 5, and 7 contain no holes, 0, 4, 6, and 9 each has one hole, and 8 contains two holes. Therefore, the answer to the puzzle is 45678 → 1 + 0 + 1 + 0 + 2 = 4.
You want to impress Elly, so you decide to write a program that will find the correct answer for certain integers. Given an integer number, print the total number of holes in that number.
Input
Input starts with an integer T (≤ 1000), denoting the number of test cases.
Each case starts with a line containing one integer N. N will be between 1 and 10000.
Output
For each test case, print one line containing the number of holes.
Example
Input: 3 41 12 669 Output: 1 0 3
Added by: | imranziad |
Date: | 2016-03-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU JS-MONKEY |
Resource: | IAPC |
hide comments
2016-03-25 17:36:56 e_coder
move to tutorial. :-P |
|
2016-03-25 10:07:41 shadowfax
Thanks Blue.Mary... edited |
|
2016-03-25 10:06:36 [Rampage] Blue.Mary
The number of test cases in the sample input should be 3 instead of 2. |