Problem Statement
Cyclists don't like the number eight because it symbolizes a broken wheel. Recently, the mayor of Moscow decided to force all cyclists to get an identification number. Vasya was presented with the following choice: he can choose any number between low and high, inclusive. He wants his number to contain as few eights as possible. Return the minimal possible number of eights he can have in his number.
Definition
- Class:
- NoEights
- Method:
- smallestAmount
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int smallestAmount(int low, int high)
- (be sure your method is public)
Constraints
- low will be between 1 and 2000000000, inclusive.
- high will be between low and 2000000000, inclusive.
Examples
1
10
Returns: 0
Any number except 8 will do.88
88
Returns: 2
The only possible number is 88.800
899
Returns: 1
The first 8 is unavoidable.8808
8880
Returns: 2