November 25th, 2010
Last time I was home I found my old "Drive Ya Nuts" puzzle. I don't remember ever solving it. Here it is, unsolved, in all its frustrating glory.
This Thanksgiving I'm on a long overnight in Nashville, TN so I wrote a prolog program to end this once and for all. New puzzles come solved in the retail box but there is no good reason to believe that this is the only solution.
use_module(library(lists)). % Nuts. nut(t, 1, 2, 3, 4, 5, 6). nut(u, 1, 2, 5, 6, 3, 4). nut(v, 1, 3, 5, 2, 4, 6). nut(w, 1, 3, 5, 4, 2, 6). nut(x, 1, 4, 2, 3, 5, 6). nut(y, 1, 5, 3, 2, 6, 4). nut(z, 1, 6, 5, 4, 3, 2). % Rotation successors. succ(r0, r1). succ(r1, r2). succ(r2, r3). succ(r3, r4). succ(r4, r5). % A nut is zero rotated if marks match % a nut definition. rotate(r0, nut(Name,A,B,C,D,E,F)) :- nut(Name,A,B,C,D,E,F). % A nut is rotated R if there is a % sequence of preceding rotations. rotate(R, nut(Name,A,B,C,D,E,F)) :- succ(PrevR, R), rotate(PrevR, nut(Name,F,A,B,C,D,E)). % Solution for the seven (*) pegs. % Letter variables are matching edges. % * I * % J H % C B % * D * A * % E F % K G % * L * % Nuts are marked CCW starting from the % right edge. solution(Center, Right, TopRight, TopLeft, Left, BottomLeft, BottomRight) :- Center = nut(N1, A,B,C,D,E,F), Right = nut(N2, _,_,H,A,G,_), TopRight = nut(N3, _,_,_,I,B,H), TopLeft = nut(N4, I,_,_,_,J,C), Left = nut(N5, D,J,_,_,_,K), BottomLeft = nut(N6, L,E,K,_,_,_), BottomRight = nut(N7, _,G,F,L,_,_), rotate(r0, Center), rotate(_, Right), rotate(_, TopRight), rotate(_, TopLeft), rotate(_, Left), rotate(_, BottomLeft), rotate(_, BottomRight), permutation([t,u,v,w,x,y,z], [N1,N2,N3,N4,N5,N6,N7]).
?- [drive_ya_nuts]. % drive_ya_nuts compiled 0.00 sec, -48 bytes true. ?- solution(A,B,C,D,E,F,G). A = nut(w, 1, 3, 5, 4, 2, 6), B = nut(y, 2, 6, 4, 1, 5, 3), C = nut(t, 5, 6, 1, 2, 3, 4), D = nut(v, 2, 4, 6, 1, 3, 5), E = nut(z, 4, 3, 2, 1, 6, 5), F = nut(u, 1, 2, 5, 6, 3, 4), G = nut(x, 3, 5, 6, 1, 4, 2) ; false. ?-
Yup, only one solution. I bought this puzzle used at a garage sale around 1990 so it hasn't been arranged for at least 20 years. I'd love to get some insight that makes the computer unnecessary but this is good enough for now. Happy Thanksgiving!