Statistics

Problem Statement for "Plates"

Problem Statement

Recently all cars in NJ had a specific pattern of digits and letters for their license plate numbers. For example, the license plate number "UG830H" follows the pattern "LLDDDL", where 'L' stands for letter, and 'D' stands for digit. 17,576,000 distinct license plate numbers can be generated using this format. As the population and the number of cars grows, new formats appear. For example, the new format in NJ is "LLLDDL" (as in "MEL87H"). The new format will be able to number 45,697,600 cars. Assume that plates are assigned in lexicographic order (the order they would appear in a dictionary. i.e. "AAA" comes before "AAB" and "AA1" comes before "AA7"). For practical purposes it is important to know how many plates are available for further assignment at each moment in time.

Your task is, given a String representing a license plate number, return the total number of possible license plates following the same pattern as the input that can be assigned after the given plate number.

For example, given the String "D43", we must count all of the plate numbers that have one letter, followed by two digits, and come after "D43". Any sequence that starts with a letter after 'D' works (there are 100*22 of these), as does any sequence that starts with the letter 'D' and is followed by a two digit number greater than "43" (there are 56 of these).

Definition

Class:
Plates
Method:
numLeft
Parameters:
String
Returns:
long
Method signature:
long numLeft(String plateNum)
(be sure your method is public)

Notes

  • We assume that only upper-case letters and digits can be used in plate numbers.
  • Digit 0 (zero) should be treated like any other digit. That is, the plate number can start with 0, if it starts with a digit.
  • The 64 bit datatype in C++ is long long.

Constraints

  • plateNum contains between 3 and 8 characters inclusive
  • each character of plateNum is a digit ('0'-'9') or an upper-case letter ('A'-'Z')

Examples

  1. "222"

    Returns: 777

    plates are made of three digits starting from "000" and ending with "999".

  2. "TA4KA"

    Returns: 1227355

  3. "KAPETA"

    Returns: 189835177

  4. "MAPA3M"

    Returns: 63875149

  5. "ZZZZZ"

    Returns: 0

  6. "AAAAAAAA"

    Returns: 208827064575

  7. "ZZA"

    Returns: 25

  8. "ZAA"

    Returns: 675

  9. "ZAZ"

    Returns: 650

  10. "AZZ"

    Returns: 16900

  11. "AZA"

    Returns: 16925

  12. "AAZ"

    Returns: 17550

  13. "Z9Z9"

    Returns: 0

  14. "FEB29"

    Returns: 1409070

  15. "AAAZZZZZ"

    Returns: 208815183200

  16. "ZZAAAAAA"

    Returns: 308915775

  17. "ZAAAAAAA"

    Returns: 8031810175

  18. "12345678"

    Returns: 87654321

  19. "00000000"

    Returns: 99999999

  20. "A0A0A0A0"

    Returns: 4569759999

  21. "HMM333HA"

    Returns: 8463294709

  22. "D43"

    Returns: 2256

  23. "KAPETA"

    Returns: 189835177

  24. "AAA"

    Returns: 17575

  25. "AAAAAAAA"

    Returns: 208827064575

  26. "222"

    Returns: 777

  27. "MAPA3M"

    Returns: 63875149

  28. "AK51DDK"

    Returns: 1169663107

  29. "H3AB5RZ0"

    Returns: 8545345129

  30. "TA47KA"

    Returns: 12271167

  31. "AAAZ97"

    Returns: 45695002

  32. "ZZZZZZZZ"

    Returns: 0

  33. "KAPETA4B"

    Returns: 49357146174

  34. "BBBBBBBB"

    Returns: 200473981992

  35. "AMBROSE"

    Returns: 7888467959

  36. "Z00Z0AB"

    Returns: 17406998

  37. "AAAABAAA"

    Returns: 208827046999

  38. "AAAAAABA"

    Returns: 208827064549


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: