TopCoder problem "JumpyNum" used in SRM 300 (Division I Level Two)



Problem Statement

    A jumpy number is a positive integer, all of whose adjacent digits differ by at least 2. For example,
        
        NOT JUMPY: 28459, 28549, 1091919, 97753, 111111
            JUMPY: 290464, 13131313, 97539753, 5
Create a class JumpyNum that contains a method howMany that is given low and high and returns the number of jumpy numbers that are between low and high, inclusive.
 

Definition

    
Class:JumpyNum
Method:howMany
Parameters:int, int
Returns:int
Method signature:int howMany(int low, int high)
(be sure your method is public)
    
 

Constraints

-low is between 1 and 2,000,000,000, inclusive.
-high is between low and 2,000,000,000, inclusive.
 

Examples

0)
    
1
10
Returns: 9
All the single digit numbers are jumpy, but 10 isn't since 1 and 0 differ by only 1.
1)
    
9
23
Returns: 9
The jumpy ones are 9,13,14,15,16,17,18,19,20
2)
    
2000000000
2000000000
Returns: 0
3)
    
8000
20934
Returns: 3766

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=9821&pm=4848

Writer:

dgoodman

Testers:

PabloGilberto , lbackstrom , brett1479 , vorthys , Olexiy

Problem categories:

Dynamic Programming