Statistics

Problem Statement for "EllysTimeMachine"

Problem Statement

Elly has invented a simple time machine! Unfortunately, it cannot change the time by more than several hours. But sometimes several hours is all a person needs...

The time machine has a wall clock with two hands: a small hand that shows the hour and a large hand that shows the minutes. Both hands move in discrete steps. The minute hand moves to show the correct time whenever the number of minutes reaches a multiple of 5. The hour hand moves to show the correct time each whole hour. This means that at any moment, the hour hand points to one of the numbers 01, 02, 03, ..., 11, and 12. Additionally, at any moment, the minute hand also points to one of those numbers, but we interpret them as minutes: :05, :10, :15, ..., :55, and :00.

The time machine behaves in a peculiar way: when activated, it jumps to such a time that the two hands on the clock switch positions. For example, suppose the current time is 11:20. On the clock, the hour hand points to 11 and the minute hand points to 04 (that represents :20). As Elly activated the time machine, the hands switched positions: now the hour hand points to 04 and the minute hand points to 11. Thus, the time machine jumped to the time 04:55. See the sample test cases for other examples of how the time machine works.

You are given the current time in the String time in the format "HH:MM", where HH are the hours (a two-digit number between 01 and 12, inclusive), and MM are the minutes (a two-digit number between 00 and 55, inclusive). Compute the new time after the time machine is activated. Return that time in the same format.

Definition

Class:
EllysTimeMachine
Method:
getTime
Parameters:
String
Returns:
String
Method signature:
String getTime(String time)
(be sure your method is public)

Notes

  • Please note that the required time formatting always requires two digits both for the hour and the minutes (i.e. the numbers are padded with leading zeroes when needed).

Constraints

  • time will contain exactly 5 characters and will be formatted as "HH:MM".
  • HH will be one of {01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12}.
  • MM will be one of {00, 05, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55}.

Examples

  1. "11:20"

    Returns: "04:55"

    The example from the problem statement.

  2. "02:25"

    Returns: "05:10"

  3. "06:30"

    Returns: "06:30"

  4. "05:55"

    Returns: "11:25"

  5. "03:45"

    Returns: "09:15"

  6. "01:00"

    Returns: "12:05"

  7. "01:05"

    Returns: "01:05"

  8. "01:10"

    Returns: "02:05"

  9. "01:15"

    Returns: "03:05"

  10. "01:20"

    Returns: "04:05"

  11. "01:25"

    Returns: "05:05"

  12. "01:30"

    Returns: "06:05"

  13. "01:35"

    Returns: "07:05"

  14. "01:40"

    Returns: "08:05"

  15. "01:45"

    Returns: "09:05"

  16. "01:50"

    Returns: "10:05"

  17. "01:55"

    Returns: "11:05"

  18. "02:00"

    Returns: "12:10"

  19. "02:05"

    Returns: "01:10"

  20. "02:10"

    Returns: "02:10"

  21. "02:15"

    Returns: "03:10"

  22. "02:20"

    Returns: "04:10"

  23. "02:25"

    Returns: "05:10"

  24. "02:30"

    Returns: "06:10"

  25. "02:35"

    Returns: "07:10"

  26. "02:40"

    Returns: "08:10"

  27. "02:45"

    Returns: "09:10"

  28. "02:50"

    Returns: "10:10"

  29. "02:55"

    Returns: "11:10"

  30. "03:00"

    Returns: "12:15"

  31. "03:05"

    Returns: "01:15"

  32. "03:10"

    Returns: "02:15"

  33. "03:15"

    Returns: "03:15"

  34. "03:20"

    Returns: "04:15"

  35. "03:25"

    Returns: "05:15"

  36. "03:30"

    Returns: "06:15"

  37. "03:35"

    Returns: "07:15"

  38. "03:40"

    Returns: "08:15"

  39. "03:45"

    Returns: "09:15"

  40. "03:50"

    Returns: "10:15"

  41. "03:55"

    Returns: "11:15"

  42. "04:00"

    Returns: "12:20"

  43. "04:05"

    Returns: "01:20"

  44. "04:10"

    Returns: "02:20"

  45. "04:15"

    Returns: "03:20"

  46. "04:20"

    Returns: "04:20"

  47. "04:25"

    Returns: "05:20"

  48. "04:30"

    Returns: "06:20"

  49. "04:35"

    Returns: "07:20"

  50. "04:40"

    Returns: "08:20"

  51. "04:45"

    Returns: "09:20"

  52. "04:50"

    Returns: "10:20"

  53. "04:55"

    Returns: "11:20"

  54. "05:00"

    Returns: "12:25"

  55. "05:05"

    Returns: "01:25"

  56. "05:10"

    Returns: "02:25"

  57. "05:15"

    Returns: "03:25"

  58. "05:20"

    Returns: "04:25"

  59. "05:25"

    Returns: "05:25"

  60. "05:30"

    Returns: "06:25"

  61. "05:35"

    Returns: "07:25"

  62. "05:40"

    Returns: "08:25"

  63. "05:45"

    Returns: "09:25"

  64. "05:50"

    Returns: "10:25"

  65. "05:55"

    Returns: "11:25"

  66. "06:00"

    Returns: "12:30"

  67. "06:05"

    Returns: "01:30"

  68. "06:10"

    Returns: "02:30"

  69. "06:15"

    Returns: "03:30"

  70. "06:20"

    Returns: "04:30"

  71. "06:25"

    Returns: "05:30"

  72. "06:30"

    Returns: "06:30"

  73. "06:35"

    Returns: "07:30"

  74. "06:40"

    Returns: "08:30"

  75. "06:45"

    Returns: "09:30"

  76. "06:50"

    Returns: "10:30"

  77. "06:55"

    Returns: "11:30"

  78. "07:00"

    Returns: "12:35"

  79. "07:05"

    Returns: "01:35"

  80. "07:10"

    Returns: "02:35"

  81. "07:15"

    Returns: "03:35"

  82. "07:20"

    Returns: "04:35"

  83. "07:25"

    Returns: "05:35"

  84. "07:30"

    Returns: "06:35"

  85. "07:35"

    Returns: "07:35"

  86. "07:40"

    Returns: "08:35"

  87. "07:45"

    Returns: "09:35"

  88. "07:50"

    Returns: "10:35"

  89. "07:55"

    Returns: "11:35"

  90. "08:00"

    Returns: "12:40"

  91. "08:05"

    Returns: "01:40"

  92. "08:10"

    Returns: "02:40"

  93. "08:15"

    Returns: "03:40"

  94. "08:20"

    Returns: "04:40"

  95. "08:25"

    Returns: "05:40"

  96. "08:30"

    Returns: "06:40"

  97. "08:35"

    Returns: "07:40"

  98. "08:40"

    Returns: "08:40"

  99. "08:45"

    Returns: "09:40"

  100. "08:50"

    Returns: "10:40"

  101. "08:55"

    Returns: "11:40"

  102. "09:00"

    Returns: "12:45"

  103. "09:05"

    Returns: "01:45"

  104. "09:10"

    Returns: "02:45"

  105. "09:15"

    Returns: "03:45"

  106. "09:20"

    Returns: "04:45"

  107. "09:25"

    Returns: "05:45"

  108. "09:30"

    Returns: "06:45"

  109. "09:35"

    Returns: "07:45"

  110. "09:40"

    Returns: "08:45"

  111. "09:45"

    Returns: "09:45"

  112. "09:50"

    Returns: "10:45"

  113. "09:55"

    Returns: "11:45"

  114. "10:00"

    Returns: "12:50"

  115. "10:05"

    Returns: "01:50"

  116. "10:10"

    Returns: "02:50"

  117. "10:15"

    Returns: "03:50"

  118. "10:20"

    Returns: "04:50"

  119. "10:25"

    Returns: "05:50"

  120. "10:30"

    Returns: "06:50"

  121. "10:35"

    Returns: "07:50"

  122. "10:40"

    Returns: "08:50"

  123. "10:45"

    Returns: "09:50"

  124. "10:50"

    Returns: "10:50"

  125. "10:55"

    Returns: "11:50"

  126. "11:00"

    Returns: "12:55"

  127. "11:05"

    Returns: "01:55"

  128. "11:10"

    Returns: "02:55"

  129. "11:15"

    Returns: "03:55"

  130. "11:20"

    Returns: "04:55"

  131. "11:25"

    Returns: "05:55"

  132. "11:30"

    Returns: "06:55"

  133. "11:35"

    Returns: "07:55"

  134. "11:40"

    Returns: "08:55"

  135. "11:45"

    Returns: "09:55"

  136. "11:50"

    Returns: "10:55"

  137. "11:55"

    Returns: "11:55"

  138. "12:00"

    Returns: "12:00"

  139. "12:05"

    Returns: "01:00"

  140. "12:10"

    Returns: "02:00"

  141. "12:15"

    Returns: "03:00"

  142. "12:20"

    Returns: "04:00"

  143. "12:25"

    Returns: "05:00"

  144. "12:30"

    Returns: "06:00"

  145. "12:35"

    Returns: "07:00"

  146. "12:40"

    Returns: "08:00"

  147. "12:45"

    Returns: "09:00"

  148. "12:50"

    Returns: "10:00"

  149. "12:55"

    Returns: "11:00"


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: