The Cracker Barrel
Puzzle
Here is the
numbering system we use...
1
2
3
4
5 6
7
8 9 10
11
12 13 14 15
And here are the
steps.
Start
1
2
3
4
- 6
7
8 9 10
11
12 13
14 15
12
8 5
1
2
3
4
5 6
7 - 9 10
11 - 13 14 15
14
13 12
1
2
3
4
5 6
7
- 9 10
11
12 - - 15
6
9 13
1
2
3
4 5 -
7
- - 10
11
12 13 - 15
15
10 6
1
2
3
4
5 6
7
- - -
11 12 13
- -
12
13 14
1
2 3
4 5 6
7
- - -
11
- - 14 -
2
5 9
1
-
3
4
- 6
7
- 9 -
11
- - 14 -
3
6 10
1
-
-
4
- -
7 -
9 10
11 -
- 14 -
7
4 2
1
2
-
- - -
-
- 9 10
11
- - 14 -
10
9 8
1
2 -
- - -
-
8 - -
11
- - 14 -
1
2 4
-
-
-
4 - -
-
8 - -
11
- - 14 -
4
8 13
-
-
-
-
- -
-
- - -
11
- 13
14 -
14
13 12
-
-
-
- - -
-
- - -
11 12 - - -
11
12 13
-
-
-
-
- -
-
- - -
- -
13 - -
%Here is the MATLAB
code that finds solutions randomly.
GAMES=10000;
board=ones(15,1);board(5)=0;
mo=[1 2 4 ;
1 3 6 ;
2 4 7;
2 5 9 ;
3 5 8 ;
3 6 10;
4 2 1;
4 5 6;
4 7 11;
4 8 13;
5 8 12 ;
5 9 14;
6 3 1;
6 5 4;
6 9 13;
6 10 15;
7 4 2;
7 8 9;
8 5 3;
8 9 10;
9 8 7;
9 5 3 ;
10 6 3;
10 9 8;
11 7 4;
11 12 13;
12 8 5
12 13 14;
13 8 4;
13 9 6;
13 12 11;
13 14 15;
14 9 5;
14 13 12;
15 14 13;
15 10 6];
for g=1:GAMES
if mod(g,25)==0;g,end;
bd=board;
sequence=[0 0 0]';
SUMold=14;
while sum(bd)>1;
[x i]=sort(rand(36,1));
for m=1:36
n=i(m);
if bd(mo(n,1))==1 &
bd(mo(n,2))==1 & bd(mo(n,3))==0;
bd(mo(n,1))=0 ;bd(mo(n,2))=0 ;
bd(mo(n,3))=1;
sequence = [sequence
(mo(n,:))'];
break
end
end
if SUMold==sum(bd)
break
else
SUMold=sum(bd);
end
end
if sum(bd)==1;
break
end
end
g
sum(bd)
sequence
HERE IS A SOLUTION
FROM THE PROGRAM
12
8 5
14
13 12
6
9 13
15
10 6
12
13 14
2
5 9
3
6 10
7
4 2
10
9 8
1
2 4
4
8 13
14
13 12
11
12 13