Statistics

Problem Statement for "FussySleeper"

Problem Statement

Last night, after that terrible nightmare about pink elephants, you decided that you would never again go to sleep unless the time showing on your digital clock was a multiple of the number of elephants in your dream. Rather than waiting and constantly checking the clock, you decide to calculate the earliest time after the current time that you can go to sleep. Write a method which takes the currentTime on your clock, and the number of elephants in your dream, and returns the earliest future time that is a multiple of elephants.

currentTime will be a int[] containing exactly two elements. The first element is the current hour value on the clock (between 0 and 23, inclusive), and the second element is the current minute (between 0 and 59, inclusive). The returned int[] must also follow this format.

The time on the clock is a multiple of some number k whenever the digits on the clock form a four-digit number ('HHMM') which is divisible by k - for example 10:01 is divisible by 11 (1001 = 11 * 91), but 01:04 is not divisible by 7 (104 = 14 * 7 + 6). Even if you can fall asleep at the current time, you must return the next time you can fall asleep.

Definition

Class:
FussySleeper
Method:
nextTime
Parameters:
int[], int
Returns:
int[]
Method signature:
int[] nextTime(int[] currentTime, int elephants)
(be sure your method is public)

Constraints

  • currentTime will be as described in the statement.
  • elephants will be between 1 and 1000, inclusive.

Examples

  1. {21, 30}

    100

    Returns: {22, 0 }

    You are able to sleep at the top of every hour. The earliest future time that satisfies this requirement is 22:00 (2200 = 22 x 100).

  2. {20, 30}

    23

    Returns: {20, 47 }

    You just missed your chance to sleep at 20:24 (2024 = 23 x 88) but your next chance is at 20:47

  3. {23,55}

    1

    Returns: {23, 56 }

    With only one elephant, you can sleep every minute, so the next possible time is 23:56

  4. {0, 0}

    999

    Returns: {0, 0 }

    With so many elephants in your dream, the only time you can sleep is at midnight. Although you can't sleep currently, you will be able to the next time the clock hits "00:00".

  5. {12, 59}

    1

    Returns: {13, 0 }

    testing elephants = 1

  6. {10, 31}

    494

    Returns: {0, 0 }

  7. {4, 39}

    833

    Returns: {8, 33 }

  8. {15, 49}

    225

    Returns: {18, 0 }

  9. {0, 21}

    265

    Returns: {5, 30 }

  10. {2, 3}

    5

    Returns: {2, 5 }

  11. {15, 42}

    815

    Returns: {16, 30 }

  12. {5, 0}

    968

    Returns: {19, 36 }

  13. {5, 10}

    977

    Returns: {19, 54 }

  14. {12, 45}

    669

    Returns: {13, 38 }

  15. {22, 16}

    315

    Returns: {0, 0 }

  16. {17, 17}

    121

    Returns: {18, 15 }

  17. {2, 5}

    687

    Returns: {0, 0 }

  18. {3, 39}

    260

    Returns: {5, 20 }

  19. {16, 36}

    992

    Returns: {0, 0 }

  20. {23, 39}

    540

    Returns: {0, 0 }

  21. {14, 40}

    714

    Returns: {21, 42 }

  22. {16, 19}

    184

    Returns: {16, 56 }

  23. {3, 34}

    632

    Returns: {6, 32 }

  24. {9, 26}

    973

    Returns: {19, 46 }

  25. {11, 6}

    456

    Returns: {18, 24 }

  26. {16, 0}

    93

    Returns: {19, 53 }

  27. {13, 57}

    452

    Returns: {18, 8 }

  28. {18, 6}

    31

    Returns: {18, 29 }

  29. {2, 44}

    615

    Returns: {6, 15 }

  30. {6, 57}

    972

    Returns: {19, 44 }

  31. {11, 21}

    40

    Returns: {12, 0 }

  32. {20, 22}

    337

    Returns: {23, 59 }

  33. {23,58}

    7

    Returns: {23, 59 }

  34. {23,58}

    131

    Returns: {0, 0 }

  35. {0, 1 }

    999

    Returns: {0, 0 }

  36. {0, 0 }

    1

    Returns: {0, 1 }

  37. {21, 0 }

    100

    Returns: {22, 0 }

  38. {0, 2 }

    3

    Returns: {0, 3 }

  39. {10, 10 }

    10

    Returns: {10, 20 }

  40. {0, 0 }

    2

    Returns: {0, 2 }

  41. {9, 59 }

    1000

    Returns: {10, 0 }

  42. {0, 0 }

    60

    Returns: {1, 20 }

  43. {23, 59 }

    100

    Returns: {0, 0 }

  44. {23, 5 }

    5

    Returns: {23, 10 }

  45. {23, 0 }

    23

    Returns: {23, 23 }

  46. {0, 0 }

    197

    Returns: {0, 0 }

  47. {5, 59 }

    1

    Returns: {6, 0 }

  48. {1, 0 }

    11

    Returns: {1, 10 }

  49. {0, 59 }

    1

    Returns: {1, 0 }

  50. {23, 55 }

    15

    Returns: {0, 0 }

  51. {23, 59 }

    3

    Returns: {0, 0 }

  52. {23, 59 }

    17

    Returns: {0, 0 }

  53. {22, 5 }

    5

    Returns: {22, 10 }

  54. {5, 59 }

    560

    Returns: {11, 20 }

  55. {23, 58 }

    337

    Returns: {23, 59 }

  56. {12, 1 }

    601

    Returns: {12, 2 }

  57. {2, 59 }

    9

    Returns: {3, 6 }

  58. {10, 50 }

    535

    Returns: {16, 5 }

  59. {0, 0 }

    100

    Returns: {1, 0 }

  60. {2, 0 }

    2

    Returns: {2, 2 }


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: