25
2
I like to save time quite literally, by wearing three watches on my wrist... Problem is they each give a different time. One watch is x minutes behind the actual time. One watch is x minutes ahead of the actual time. The last watch shows the actual time.
Problem is, I can't tell which watch has the correct time...
From the time displayed on each watch, determine the actual time. If it is not possible to determine the time, print "Look at the sun".
Input:
Three readings, separated by single space characters: H1:M1 H2:M2 H3:M3
In each reading H1,H2,H3 represent the hours displayed (0 < H1,H2,H3 < 13), and
M1,M2,M3 represent the minutes displayed (0 <= M1,M2,M3 < 60). If the number of
minutes is less than 10, a leading 0 is prepended in the input. Similarly, is the number of hours is less than 10, a leading 0 is prepended in the input.
Output: The correct time is HH:MM
where HH:MM is the correct time. If no correct time can be determined, it displays Look at the sun
.
Input 1: 05:00 12:00 10:00
Output 1: The correct time is 05:00
Input 2: 11:59 12:30 01:01
Output 2: The correct time is 12:30
Input 3: 12:00 04:00 08:00
Output 3: Look at the sun
Shortest code wins... No special penalties apply. Also, bear in mind that we're dealing with a 12-hour clock... I don't care about AM or PM... Imagine we're dealing with analogue watches...
By correct time, you mean the current local time ? – Optimizer – 2015-06-03T06:21:05.840
@Optimizer One of the watches will contain the correct time, the other two will be X minutes plus/minus from the correct time... I've mentioned that in the brief... – WallyWest – 2015-06-03T06:27:47.387
@Dennis Output 3 clearly shows a response of
Look at the sun
, so yes... – WallyWest – 2015-06-03T07:09:18.110Why is Output 3
look at the sun
? Would8:00
not be correct, and why not? – Sanchises – 2015-06-03T07:27:24.5407@sanchises Because they're 4 hours apart.
12:00
is exactly between8:00
and4:00
too, you know... – Siguza – 2015-06-03T07:40:45.273@Siguza I knew I was missing something obvious! – Sanchises – 2015-06-03T12:32:52.770
1You say the output is of the form
The correct time is HH:MM
, without a full stop, but then proceed to include a full stop in the first two examples. Which version is correct? – Sp3000 – 2015-06-03T15:49:39.420Also additional test case:
07:21 08:39 08:00
– Sp3000 – 2015-06-03T16:03:10.8171Is it allowed to to read the times as command line arguments? – Dennis – 2015-06-03T16:38:56.637
1As in
whattimeisit 07:21 08:39 08:00
? Sure! – WallyWest – 2015-06-03T23:43:15.177@Sp3000 Valid point, I've corrected the output format... – WallyWest – 2015-06-03T23:45:05.370