Statistics

Problem Statement for "TheLuckyNumbersLevelOne"

Problem Statement

The digits 4 and 7 are lucky digits, and all other digits are unlucky. A first level lucky number is a positive integer whose decimal representation is a palindrome that contains only lucky digits. A palindrome is a number that reads the same forward and backward. John and Brus would like to count the number of first level lucky numbers within a specified range.

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

Definition

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

Constraints

  • a will be between 1 and 10^18, inclusive.
  • b will be between a and 10^18, inclusive.

Examples

  1. 1

    100

    Returns: 4

    The first level lucky numbers within this range are 4, 7, 44 and 77.

  2. 45

    54

    Returns: 0

    There are no first level lucky numbers here.

  3. 477444774

    477444774

    Returns: 1

    The given range contains only one integer and it is a first level lucky number.

  4. 456789123

    789123456

    Returns: 24

  5. 70

    100

    Returns: 1

  6. 71

    76

    Returns: 0

  7. 15

    77

    Returns: 2

  8. 314415

    748518739

    Returns: 64

  9. 839685

    294794236

    Returns: 32

  10. 720206

    863378607

    Returns: 68

  11. 987391

    91823502

    Returns: 32

  12. 374770

    454911421

    Returns: 48

  13. 925976

    253992901

    Returns: 32

  14. 31515

    815601503

    Returns: 80

  15. 993966

    789622502

    Returns: 64

  16. 461339

    14618776

    Returns: 22

  17. 533801

    299889533

    Returns: 36

  18. 486946

    461720850

    Returns: 44

  19. 358787

    201840879

    Returns: 40

  20. 980234

    2395868

    Returns: 0

  21. 91972593928314415

    429437714725840869

    Returns: 0

  22. 554102594705839685

    871864155292650254

    Returns: 256

  23. 17438115591720206

    79807977131137660

    Returns: 512

  24. 725080559573987391

    948391076642202521

    Returns: 256

  25. 535282044706616000

    968493245237374770

    Returns: 256

  26. 220418497480925976

    385179090453708371

    Returns: 0

  27. 952794849364031515

    978499011279142477

    Returns: 0

  28. 585767164920993966

    644797924620882056

    Returns: 0

  29. 798057841747051409

    851841734813461339

    Returns: 0

  30. 749070736374533801

    811873140226833474

    Returns: 128

  31. 91972593928314415

    929437714725840724

    Returns: 512

  32. 54102594705839685

    971864155292650155

    Returns: 768

  33. 17438115591720206

    979807977131137619

    Returns: 1024

  34. 25080559573987391

    948391076642202451

    Returns: 1024

  35. 68493245237374770

    935282044706615984

    Returns: 768

  36. 20418497480925976

    985179090453708307

    Returns: 1024

  37. 52794849364031515

    978499011279142317

    Returns: 768

  38. 85767164920993966

    944797924620881899

    Returns: 512

  39. 51841734813461339

    998057841747051331

    Returns: 768

  40. 49070736374533801

    911873140226833355

    Returns: 768

  41. 1

    1000000000000000000

    Returns: 2044

  42. 4

    777777777777777777

    Returns: 2044

  43. 7

    444444444444444444

    Returns: 1532

  44. 5

    536417038372758858

    Returns: 1787

  45. 8

    665213705816950778

    Returns: 1786

  46. 5

    461882560036164617

    Returns: 1659

  47. 5

    502858337351765142

    Returns: 1787

  48. 4774747444747774

    9284387456984365

    Returns: 150

  49. 11

    999999999999999999

    Returns: 2042


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: