Statistics

Problem Statement for "GoodHours"

Problem Statement

Johnny likes to watch the clock. He likes some moments more than others. The time "HH:MM" is good if you can split the four digits into two adjacent groups such that the products of the digits within each group are equal. Each group must contain at least one digit, so there are totally 3 possible ways to do the split: "H" and "H:MM", "HH" and "MM", or "HH:M" and "M". For example, "22:28" is good because you can split it into "22:2" and "8", and 2 * 2 * 2 = 8. "23:32" and "10:00" are also good, while "23:45" and "12:42" are not.


You are given two Strings, beforeTime and afterTime, each formatted as "HH:MM" (quotes for clarity). The two times are less than 24 hours apart. Return the number of good times between beforeTime and afterTime, inclusive.

Definition

Class:
GoodHours
Method:
howMany
Parameters:
String, String
Returns:
int
Method signature:
int howMany(String beforeTime, String afterTime)
(be sure your method is public)

Constraints

  • beforeTime and afterTime will both be formatted as "HH:MM" (quotes for clarity), where HH is a two digit integer between 00 and 23, inclusive, and MM is a two digit integer between 00 and 59, inclusive.

Examples

  1. "00:00"

    "23:59"

    Returns: 279

  2. "11:11"

    "11:11"

    Returns: 1

    Of course, 11:11 is good.

  3. "12:22"

    "12:21"

    Returns: 279

  4. "12:32"

    "11:31"

    Returns: 272

  5. "00:56"

    "12:32"

    Returns: 164

  6. "00:00"

    "00:59"

    Returns: 60

  7. "10:10"

    "10:20"

    Returns: 2

    Only 10:10 and 10:20 are good here.

  8. "20:01"

    "20:10"

    Returns: 10

  9. "13:31"

    "14:21"

    Returns: 4

  10. "22:22"

    "22:22"

    Returns: 1

  11. "12:34"

    "12:34"

    Returns: 0

  12. "17:35"

    "17:00"

    Returns: 278

  13. "20:11"

    "03:13"

    Returns: 121

  14. "13:50"

    "23:50"

    Returns: 52

  15. "19:32"

    "20:48"

    Returns: 15

  16. "02:05"

    "14:14"

    Returns: 149

  17. "21:40"

    "00:56"

    Returns: 68

  18. "23:26"

    "17:40"

    Returns: 242

  19. "22:42"

    "16:16"

    Returns: 241

  20. "05:42"

    "13:25"

    Returns: 90

  21. "13:16"

    "05:05"

    Returns: 181

  22. "15:32"

    "17:03"

    Returns: 6

  23. "00:17"

    "04:23"

    Returns: 100

  24. "09:40"

    "15:53"

    Returns: 42

  25. "10:59"

    "19:36"

    Returns: 38

  26. "11:52"

    "11:32"

    Returns: 277

  27. "07:34"

    "11:33"

    Returns: 51

  28. "05:05"

    "08:28"

    Returns: 52

  29. "12:27"

    "22:51"

    Returns: 55

  30. "10:26"

    "16:32"

    Returns: 32

  31. "17:38"

    "15:15"

    Returns: 272

  32. "23:19"

    "18:20"

    Returns: 245

  33. "16:48"

    "07:45"

    Returns: 204

  34. "02:51"

    "19:10"

    Returns: 156

  35. "21:33"

    "03:40"

    Returns: 116

  36. "21:02"

    "08:28"

    Returns: 192

  37. "13:58"

    "17:35"

    Returns: 14

  38. "02:35"

    "23:27"

    Returns: 190

  39. "01:07"

    "10:05"

    Returns: 134

  40. "06:34"

    "11:19"

    Returns: 64

  41. "02:14"

    "06:26"

    Returns: 61

  42. "16:31"

    "23:04"

    Returns: 38

  43. "20:58"

    "21:11"

    Returns: 1

  44. "16:49"

    "07:22"

    Returns: 202

  45. "13:28"

    "10:21"

    Returns: 261

  46. "10:20"

    "20:05"

    Returns: 48

  47. "04:12"

    "16:43"

    Returns: 123

  48. "02:43"

    "06:33"

    Returns: 59

  49. "04:41"

    "22:59"

    Returns: 156

  50. "08:25"

    "09:35"

    Returns: 16

  51. "16:24"

    "21:56"

    Returns: 31

  52. "11:33"

    "11:33"

    Returns: 1

  53. "12:30"

    "12:45"

    Returns: 1

  54. "23:10"

    "01:23"

    Returns: 75

    Good times here are 23:16, 23:23, 23:32, 00:00 ... 01:10, 01:20.

  55. "22:44"

    "22:44"

    Returns: 0

  56. "12:42"

    "12:42"

    Returns: 0

  57. "02:56"

    "00:00"

    Returns: 190

  58. "23:59"

    "23:50"

    Returns: 279

  59. "23:10"

    "00:00"

    Returns: 4

  60. "23:58"

    "23:57"

    Returns: 279

  61. "00:01"

    "00:00"

    Returns: 279

  62. "11:12"

    "11:10"

    Returns: 278

  63. "00:10"

    "00:59"

    Returns: 50

  64. "00:56"

    "00:55"

    Returns: 279

  65. "00:01"

    "22:11"

    Returns: 270

  66. "12:31"

    "12:30"

    Returns: 279

  67. "11:30"

    "11:15"

    Returns: 278

  68. "23:00"

    "03:00"

    Returns: 95


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: