TopCoder problem "TheLuckyNumbers" used in SRM 403 (Division I Level One , Division II Level Two)



Problem Statement

    

John thinks 4 and 7 are lucky digits, and all other digits are not lucky. A lucky number is a number that contains only lucky digits in decimal notation.

You are given ints a and b. Return the number of lucky numbers between a and b, inclusive.

 

Definition

    
Class:TheLuckyNumbers
Method:count
Parameters:int, int
Returns:int
Method signature:int count(int a, int b)
(be sure your method is public)
    
 

Constraints

-a will be between 1 and 1,000,000,000, inclusive.
-b will be between a and 1,000,000,000, inclusive.
 

Examples

0)
    
1
10
Returns: 2
There are only two lucky numbers among the first ten positive integers.
1)
    
11
20
Returns: 0
But there are none among the next ten.
2)
    
74
77
Returns: 2
These two numbers are lucky. There are no additional lucky numbers between them.
3)
    
1000000
5000000
Returns: 64

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=12175&pm=8568

Writer:

Vasyl[alphacom]

Testers:

PabloGilberto , Olexiy , marek.cygan , ivan_metelsky

Problem categories:

Brute Force