2
\$\begingroup\$

Given:

  • a 12 hour time t in hours and minutes,
  • a rotation r in degrees,

return the time shown when an analog clock that is displaying the time t is rotated r degrees clockwise.

After rotation, the hour hand will not line up with the new position of the minute hand. To correct for this, the new hour can be derived from the new position of the hour hand.

This is . The shortest solution wins. Standard loopholes apply.

Inspired by unmarked analog clocks like this one: Unmarked analog clock]

\$\endgroup\$
5
  • 2
    \$\begingroup\$ The hour hand doesn't really line up if you rotate the whole thing. Should we be basing the hour on which hours it is between? Some test cases might be nice too \$\endgroup\$
    – Jo King
    Commented Sep 16, 2019 at 3:09
  • \$\begingroup\$ @JoKing I added a line to clarify \$\endgroup\$
    – anna328p
    Commented Sep 16, 2019 at 3:13
  • \$\begingroup\$ How can we represent the time? A pair of integers, numbers of minutes since 1200, a native time object, a string like "0130" or "1:30"? \$\endgroup\$
    – Jo King
    Commented Sep 16, 2019 at 4:32
  • 5
    \$\begingroup\$ Test cases should be provided. \$\endgroup\$
    – Joel
    Commented Sep 16, 2019 at 4:44
  • 4
    \$\begingroup\$ This needs more clarification and some test cases. We have 360 degrees and 60 minutes, which means rotating by 6 degrees should move the minutes handle to the next minute. But what if we rotate by 3 degrees? Will it be same minute or the next minute? \$\endgroup\$
    – Night2
    Commented Sep 16, 2019 at 5:23

0

Browse other questions tagged or ask your own question.