# Can you come up with a test to tell if three numbers go clockwise around a clock?

If I gave you the numbers 6, 10 and 3, you could tell by a simple visualization that you could go from the first to the second to the third by moving clockwise.

Suppose though that you wanted to do a simple arithmetical comparison of the numbers to determine if this is possible. I wanted to be able to do this without enumerating all the possible cases and without caring about which of the numbers is largest. Though not difficult, it turned out to be trickier than I thought it would be and my solution was different from what I originally had in mind.

Observing members:
0
Composing members:
0
## 5 Answers

You can always get from one number to the next moving clockwise, it would just take between 30 and 330 degrees of rotation.

Given a 3-number sequence xyz, take x and add 12 to any number in the sequence less than x. This means y and z will now definitely be bigger than x. If z>y they are clockwise. If z<y it is anti-clockwise.

Basically we are using the clock here as a modulus arithmatic system, we are selecting the residues (representatives of each equivalence class) such that x is the smallest number integer (in a non-modulus sense). Then it is easy to determine if x<y<z, which occurs only when the numbers are clockwise. If this relation doesn’t hold, they must be anti-clockwise.

That works and is simpler than what I came up with. Now consider the case where numbers are arranged in a circle clockwise, but you do not know how many there are. How would you tell if 3 numbers are in clockwise order? In this case you are allowed to first find the maximum.

I realized that this is really fairly simple. Find the smallest number and keep going sequentially, wrapping around if necessary. The numbers should keep increasing.

Yup, as long as you make the shift so that the “smallest” number is what you started with, all you need to see is that the numbers keep increasing. In response to the followup question, we want to see if the middle number is in between the first and last (in a non-modulus sense). If x<z then inbetween implies clockwise, but if x>z then inbetween implies anti-clockwise.

## Answer this question