Problem Statement

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 int number, return the total number of holes in that number.

Definition

 Class: DigitHoles Method: numHoles Parameters: int Returns: int Method signature: int numHoles(int number) (be sure your method is public)

Notes

-In some fonts, the digit '4' might not contain an enclosed hole, but for this problem you should assume it does.

Constraints

-number will be between 1 and 1000, inclusive.

Examples

0)

 `42`
`Returns: 1`
 4 has one hole, and 2 has no holes.
1)

 `669`
`Returns: 3`
 Both sixes are counted.
2)

 `688`
`Returns: 5`
 Note that 8 is the only digit that has 2 holes.
3)

 `123`
`Returns: 0`
 A number without holes.
4)

 `456`
`Returns: 2`
5)

 `789`
`Returns: 3`

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=11127

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=14236&pm=11127

espr1t

Testers:

PabloGilberto , ivan_metelsky , gojira_tc

Problem categories:

Simple Search, Iteration