Statistics

Problem Statement for "SlowKeyboard"

Problem Statement

During a quest game, you need to open a door. The door has a keyboard and a small screen with 4 digit places. The door will open only if the digits shown on the screen are equal to the minutes and seconds of the correct time. Unfortunately, the keyboard is very slow, so it takes 1 second to press a key and 2 seconds to move to a different key. For example, pressing "0000" will take 4 seconds, and pressing "1212" will take 10 seconds (4 seconds for pressing keys and 3*2 = 6 seconds for moving to other keys).

You will be given the current time as "MM:SS". If the screen shows nothing when you start, return the minimum time needed to open the door.

Definition

Class:
SlowKeyboard
Method:
enterTime
Parameters:
String
Returns:
int
Method signature:
int enterTime(String time)
(be sure your method is public)

Notes

  • Seconds and minutes increase like a normal clock, so "00:00" will be the time one second after "59:59".

Constraints

  • time will be formatted as "MM:SS", where MM and SS are two-digit numbers between 00 and 59, inclusive.

Examples

  1. "59:56"

    Returns: 4

    The time will be "00:00" in 4 seconds, which is enough time to type "00:00".

  2. "59:59"

    Returns: 6

    Type "00:05" to open the door in 6 seconds.

  3. "00:00"

    Returns: 6

  4. "00:56"

    Returns: 10

  5. "12:13"

    Returns: 8

  6. "12:34"

    Returns: 10

  7. "33:12"

    Returns: 8

  8. "49:18"

    Returns: 10

  9. "10:23"

    Returns: 10

  10. "02:37"

    Returns: 10

  11. "02:22"

    Returns: 10

  12. "01:55"

    Returns: 10

  13. "02:41"

    Returns: 10

  14. "43:47"

    Returns: 8

  15. "14:29"

    Returns: 10

  16. "24:39"

    Returns: 8

  17. "33:46"

    Returns: 8

  18. "16:35"

    Returns: 9

    The best choice is to type 1644 (takes 8 seconds) and wait 1 second.

  19. "50:45"

    Returns: 10

  20. "29:29"

    Returns: 10

  21. "41:47"

    Returns: 8

  22. "01:39"

    Returns: 10

  23. "15:51"

    Returns: 8

  24. "44:08"

    Returns: 8

  25. "02:48"

    Returns: 10

  26. "50:54"

    Returns: 10

  27. "20:48"

    Returns: 10

  28. "17:47"

    Returns: 8

  29. "41:04"

    Returns: 7

  30. "32:00"

    Returns: 10

  31. "45:10"

    Returns: 10

  32. "58:41"

    Returns: 10

  33. "23:03"

    Returns: 8

  34. "44:43"

    Returns: 6

  35. "51:30"

    Returns: 10

  36. "58:26"

    Returns: 10

  37. "39:45"

    Returns: 10

  38. "21:27"

    Returns: 10

  39. "51:32"

    Returns: 10

  40. "43:49"

    Returns: 10

  41. "48:13"

    Returns: 9

  42. "58:30"

    Returns: 10

  43. "01:01"

    Returns: 9

  44. "34:51"

    Returns: 9

  45. "40:12"

    Returns: 10

  46. "44:22"

    Returns: 8

  47. "29:18"

    Returns: 10

  48. "48:40"

    Returns: 10

  49. "04:29"

    Returns: 10

  50. "59:27"

    Returns: 10

  51. "48:11"

    Returns: 10

  52. "32:50"

    Returns: 10

  53. "22:15"

    Returns: 6

  54. "47:56"

    Returns: 10

  55. "05:47"

    Returns: 8

  56. "27:45"

    Returns: 10

  57. "59:14"

    Returns: 8

  58. "37:42"

    Returns: 10

  59. "47:26"

    Returns: 10

  60. "02:47"

    Returns: 8

  61. "20:18"

    Returns: 10

  62. "15:40"

    Returns: 10

  63. "15:39"

    Returns: 10

  64. "23:53"

    Returns: 10

  65. "50:57"

    Returns: 10

  66. "29:35"

    Returns: 9

  67. "07:17"

    Returns: 10

  68. "40:11"

    Returns: 10

  69. "27:03"

    Returns: 8

  70. "38:02"

    Returns: 9

  71. "54:02"

    Returns: 9

  72. "30:19"

    Returns: 10

  73. "02:33"

    Returns: 10

  74. "42:07"

    Returns: 10

  75. "53:12"

    Returns: 10

  76. "07:15"

    Returns: 10

  77. "24:43"

    Returns: 10

  78. "48:28"

    Returns: 10

  79. "35:08"

    Returns: 10

  80. "42:25"

    Returns: 8

  81. "06:11"

    Returns: 10

  82. "30:36"

    Returns: 8

  83. "00:56"

    Returns: 10

  84. "19:48"

    Returns: 10

  85. "35:08"

    Returns: 10

  86. "11:53"

    Returns: 10

  87. "39:28"

    Returns: 10

  88. "19:25"

    Returns: 8

  89. "50:43"

    Returns: 10

  90. "05:20"

    Returns: 10

  91. "33:06"

    Returns: 8

  92. "14:13"

    Returns: 9

  93. "40:34"

    Returns: 10

  94. "05:17"

    Returns: 10

  95. "31:44"

    Returns: 10

  96. "20:29"

    Returns: 10

  97. "41:43"

    Returns: 10

  98. "16:53"

    Returns: 10

  99. "43:55"

    Returns: 8

  100. "22:07"

    Returns: 8

  101. "49:36"

    Returns: 8

  102. "20:19"

    Returns: 10

  103. "02:21"

    Returns: 8

  104. "27:16"

    Returns: 10

  105. "29:41"

    Returns: 10

  106. "24:58"

    Returns: 10

  107. "22:58"

    Returns: 10


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: