Project Euler Problem 891

A round clock only has three hands: hour, minute, second.

Project Euler Problem 891

Solution

Answer: 1541414

Let the hand positions (modulo one full turn) at time $t\in[0,12\text{ h})$ be

$$H=\frac{t}{43200},\qquad M=\frac{12t}{43200},\qquad S=\frac{720t}{43200}.$$

A clock reading is determined only up to:

  1. rotation of the whole clock, and
  2. permutation of the three indistinguishable hands.

So an ambiguous moment is a time $t$ for which there exists another time $t'\neq t$ and a nontrivial permutation $\pi$ such that

$$(H',M',S') \equiv (H,M,S)_\pi + c \pmod 1$$

for some rotation $c$.

Subtracting the first equation from the other two removes the unknown rotation.

For each nontrivial permutation we obtain a linear system modulo $1$, whose determinant gives the number of solutions in one 12-hour cycle.

There are five nontrivial permutations.


1. Swap $M,S$: $(H,M,S)\mapsto(H,S,M)$

$$\begin{cases} 11t' -719t \equiv 0\ 719t' -11t \equiv 0 \end{cases}$$

Determinant:

$$11^2-719^2=-516840.$$

Hence there are $516840$ solutions for $t$.

But $t'=t$ occurs when $M=S$, i.e.

$$708t\equiv0,$$

giving $708$ non-ambiguous fixed points.

Contribution:

$$516840-708=516132.$$


2. Swap $H,M$: $(M,H,S)$

Determinant:

$$15697.$$

Fixed points are exactly $H=M$, giving $11$ points.

Contribution:

$$15697-11=15686.$$


3. 3-cycle $(H,M,S)\mapsto(M,S,H)$

Determinant:

$$509173.$$

Only fixed point is $t=0$, so:

$$509173-1=509172.$$


4. 3-cycle $(H,M,S)\mapsto(S,H,M)$

This produces the same solution set as case 3, so it contributes no new moments.


5. Swap $H,S$: $(S,M,H)$

Determinant:

$$501143.$$

Fixed points are exactly $H=S$, giving $719$ points.

Contribution:

$$501143-719=500424.$$


The four distinct families are pairwise disjoint except for the fixed point $t=0$, which has already been excluded.

Therefore the total number of ambiguous moments is

$$516132+15686+509172+500424 =1541414.$$

So the exact answer is

Answer: 1541414