A clock state that is not solvable by 6 simultaneous moves¶

It is known that all clock states are solvable in $12$ or fewer moves. https://www.cube20.org/clock/.

However, some states are not solvable with $6$ simultaneous moves.

The followng state is not solvable 6-simul.

0  0  0
 10  6 10
  6  0  6
 
    11
  0  6  0
     3

Here is a 7-simul sequence that gives you the state:

UL: (6, -1)
   DR: (6, 1)
    \: (0, 6)
    L: (2, -3)
    R: (2, 1)
   dl: (-2, 5)
   ur: (4, -3)
In [19]:
scramble = [0, 0, 0, 10, 6, 10, 6, 0, 6, 11, 0, 6, 0, 3]
In [20]:
import numpy as np
from itertools import combinations

Z12 = Integers(12)

Each row of the following matrices correspond to one of the $14$ independent clocks. See the comments.

Each column represent a move (that is, setting the pins in some configuration and turn a dial). See the comments.

  • U represent moving the dials where the pins are up.
  • D represent moving the dials where the pins are down.

For ALL and all, we add a null move since either all the pins are up or down.

In [21]:
pin_order_notation = np.array(['UL', 'UR', 'DR', 'DL', 'U', '\\', 'L', 'R', '/', 'D', 'dl', 'dr', 'ur', 'ul', "ALL", 'all'])

U = np.array([
#    UL UR DR DL U  \  L  R  /  D  dl dr ur ul ALL all
    [1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0],  # UL
    [1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0],  # U
    [0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0],  # UR
    [1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0],  # L
    [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],  # C
    [0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0],  # R
    [0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0],  # DL
    [0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],  # D
    [0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0],  # DR
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  # yU
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  # yL
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  # yC
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  # yR
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],  # yD
], dtype=int)

D = np.array([
#     UL  UR  DR  DL  U   \   L   R   /   D   dl  dr  ur  ul ALL all
    [ 0,  1,  1,  1,  0,  0,  0,  1,  1,  1,  0,  0,  0,  1,  0,  1],  # UL
    [ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0],  # U
    [ 1,  0,  1,  1,  0,  1,  1,  0,  0,  1,  0,  0,  1,  0,  0,  1],  # UR
    [ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0],  # L
    [ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0],  # C
    [ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0],  # R
    [ 1,  1,  1,  0,  1,  1,  0,  1,  0,  0,  1,  0,  0,  0,  0,  1],  # DL
    [ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0],  # D
    [ 1,  1,  0,  1,  1,  0,  1,  0,  1,  0,  0,  1,  0,  0,  0,  1],  # DR
    [-1, -1, -1, -1,  0, -1, -1, -1, -1, -1,  0,  0, -1, -1,  0, -1],  # yU
    [-1, -1, -1, -1, -1, -1, -1,  0, -1, -1,  0, -1, -1,  0,  0, -1],  # yL
    [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  0, -1],  # yC
    [-1, -1, -1, -1, -1, -1,  0, -1, -1, -1, -1,  0,  0, -1,  0, -1],  # yR
    [-1, -1, -1, -1, -1, -1, -1, -1, -1,  0, -1, -1,  0,  0,  0, -1],  # yD
], dtype=int)
   

Let's generate all possible $6$-simul pin sets by finding all the combinations of $6$ columns in U (or D). Let $p$ represent a pin set. We construct the reduced matrix $A_p = [U_p \, D_p]$ by only picking the columns that correspond to the pin set before concatenating the two matrices to form a $14\times12$ matrix.

Now let $b$ be our scramble and check if we can find a $p$ such that $A_p x = - b$ is solvable.

If the equation do not admit a solution, Sage will throw an error:

In [42]:
M = Matrix(Z12, [[1, 0], [0, 0]])
b = vector(Z12, [1, 0])
print("A solution is", M.solve_right(b))

b = vector(Z12, [0, 1])
print("A solution is", M.solve_right(b))
The solution is (1, 0)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[42], line 6
      3 print("The solution is", M.solve_right(b))
      5 b = vector(Z12, [Integer(0), Integer(1)])
----> 6 print("The solution is", M.solve_right(b))

File /usr/lib/python3.13/site-packages/sage/matrix/matrix2.pyx:940, in sage.matrix.matrix2.Matrix.solve_right (build/cythonized/sage/matrix/matrix2.c:15990)()
    938 ret = A.matsolvemod(K.cardinality(), b)
    939 if ret.type() == 't_INT':
--> 940     raise ValueError("matrix equation has no solutions")
    941 ret = ret.Vec().sage()
    942 return (K ** self.ncols())(ret)

ValueError: matrix equation has no solutions

When the error is thrown, we just continue and try the next pin set.

Brute force¶

In [22]:
# All 6 simul pin sets
pin_sets = list(map(list, list(combinations(range(16), 6))))

# Convert to a vector in Z12
scramble = vector(Z12, scramble)

is_solvable = False
for pin_set in pin_sets:

    # Construct the Ap matrix
    Ap = Matrix(Z12, np.concatenate((U[:, pin_set], D[:, pin_set]), axis=1))

    try:
        Ap.solve_right(-scramble)
    except Exception:
        # Not solvable using this pin_set
        continue
    
    # Solvable 6-simul, so we can just quit.
    is_solvable = True
    break

if is_solvable:
    print(f"{scramble} is solvable!")
else:
    print(f"I tried {len(pin_sets)} pin sets.")
    print(f"No 6-simul pin sets were found...")
    print(f"{scramble} is therefore NOT solvable with 6 simul moves.")
I tried 8008 pin sets.
No 6-simul pin sets were found...
(0, 0, 0, 10, 6, 10, 6, 0, 6, 11, 0, 6, 0, 3) is therefore NOT solvable with 6 simul moves.

Some of the $12$-movers are solvable 6-simul. The solver finds 6-simul solutions.

In [23]:
some_scrambles_that_is_6simulable = [
    [0, 0, 0, 10, 1, 10, 3, 6, 3, 3, 2, 11, 2, 3],
    [0, 0, 4, 1, 5, 3, 0, 0, 4, 2, 3, 7, 11, 2],
    [0, 0, 4, 7, 11, 9, 0, 0, 4, 2, 9, 1, 5, 2],
    [0, 0, 8, 1, 4, 9, 1, 2, 11, 0, 4, 2, 6, 7],
    [0, 2, 0, 9, 5, 9, 4, 8, 4, 4, 9, 1, 9, 10]
]
In [ ]:
# All 6 simul pin sets
pin_sets = list(map(list, list(combinations(range(16), 6))))

for scramble in some_scrambles_that_is_6simulable:
    # convert to a vector in Z12
    scramble = vector(Z12, scramble)

    is_solvable = False
    solution = None
    for pin_set in pin_sets:

        # Construct the Ap matrix
        Ap = Matrix(Z12, np.concatenate((U[:, pin_set], D[:, pin_set]), axis=1))

        try:
            Ap.solve_right(-scramble)
        except Exception:
            # the scramble is not solvable using this pin_set
            continue
        
        # the scramble was solvable 6-simul, so we can just quit.
        is_solvable = True
        solution = Ap.solve_right(-scramble)
        break

    # Just printing stuff.
    if is_solvable:
        print(f"{scramble} is solvable!")
        print(f"Here is a solution:")

        solution = np.array(solution).astype(int)
        solution[solution > 6] = solution[solution > 6] - 12
        
        print("pin_set: ", end="")
        for _pin in pin_order_notation[pin_set]:
            print(f"{_pin:>3}", end=" ")
        print()
        print("UP:      ", end="")
        for _sol in solution[:6]:
            print(f"{_sol:>3}", end=" ")
        print()
        print("DOWN:    ", end="")
        for _sol in solution[6:]:
            print(f"{_sol:>3}", end=" ")
        print("\n")
    else:
        print(f"I tried {len(pin_sets)} pin sets.")
        print(f"No 6-simul pin sets were found...")
        print(f"{scramble} is therefore NOT solvable with 6 simul moves.\n")
(0, 0, 0, 10, 1, 10, 3, 6, 3, 3, 2, 11, 2, 3) is solvable!
Here is a solution:
pin_set:  UL   \   L   R   D  dl 
UP:        5   5   4  -3  -1   1 
DOWN:     -2  -1  -3   1  -4  -4 

(0, 0, 4, 1, 5, 3, 0, 0, 4, 2, 3, 7, 11, 2) is solvable!
Here is a solution:
pin_set:  UR   \   L   R   D  dr 
UP:       -5   5  -2   1  -5   1 
DOWN:     -1   3   3   4   5   5 

(0, 0, 4, 7, 11, 9, 0, 0, 4, 2, 9, 1, 5, 2) is solvable!
Here is a solution:
pin_set:  UR   \   L   R   D  dr 
UP:        1  -1  -2  -5   1  -5 
DOWN:      5  -3  -3   4  -1  -1 

(0, 0, 8, 1, 4, 9, 1, 2, 11, 0, 4, 2, 6, 7) is solvable!
Here is a solution:
pin_set:  UL   U   \   R   D  ur 
UP:        5   5  -3  -3  -4  -4 
DOWN:      1   2   6  -2  -1  -4 

(0, 2, 0, 9, 5, 9, 4, 8, 4, 4, 9, 1, 9, 10) is solvable!
Here is a solution:
pin_set:  DR   U   L   R   /  ur 
UP:       -3   3   4  -5   3   5 
DOWN:     -5  -3   1   4   1   3