198 http://inventwithpython.com/hacking
Email questions to the author: [email protected]
3 O’Clock + 5 Hours = 8 O’Clock
If the current time is 3 o’clock, what time will it be in 5 hours? This is
easy enough to figure out. 3 + 5 = 8. It will be 8 o’clock. Think of the
hour hand on the clock in Figure 14- 1 starting at 3, and then moving 5
hours clockwise. It will end up at 8. This is one way we can double-
check our math.
10 O’Clock + 5 Hours = 3 O’Clock
If the current time is 10 o’clock, what time will it be in 5 hours? If you
add 10 + 5, you get 15. But 15 o’clock doesn’t make sense for clocks
like the one to the right. It only goes up to 12. So to find out what time
it will be, we subtract 15 – 12 = 3. The answer is it will be 3 o’clock.
(Whether or not it is 3 AM or 3PM depends on if the current time is 10
AM or 10 PM. But it doesn’t matter for modular arithmetic.)
If you think of the hour hand as starting at 10 and then moving forward
5 hours, it will land on 3. So double-checking our math by moving the
hour hand clockwise shows us that we are correct.
10 O’Clock + 200 Hours = 6 O’Clock
If the current time is 10 o’clock, what time will it be in 200 hours? 200
- 10 = 210, and 210 is larger than 12. So we subtract 210 – 12 = 198.
But 198 is still larger than 12, so we subtract 12 again. 198 – 12 = 186.
If we keep subtracting 12 until the difference is less than 12, we end up
with 6. If the current time is 10 o’clock, the time 200 hours later will be
6 o’clock.
If we wanted to double check our 10 o’clock + 200 hours math, we
would keep moving the hour hand around and around the clock face.
When we’ve moved the hour hand the 200th time, it will end up landing
on 6.