TopcoderArchiveVisit Topcoder
SRM1 Nov 2010
SRM 510

TheAlmostLuckyNumbersDivTwo

Problem statement, definition, constraints, and public examples.

Problem Statement

John and Brus believe that the digits 4 and 7 are lucky and all others are not. According to them, an almost lucky number is a number that contains at most one non-lucky digit in its decimal representation. Return the total number of almost lucky numbers between a and b, inclusive.

Definition

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

Constraints

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

Examples

  1. 4
    7
    Returns: 4
    All numbers between 4 and 7 are almost lucky.
  2. 8
    19
    Returns: 4
    Numbers 8, 9, 14 and 17 are almost lucky.
  3. 28
    33
    Returns: 0
    No almost lucky numbers here.
  4. 1234
    4321
    Returns: 36
Back to all problems