# Crack it if you can? But in the best way

From the Wolfram Community posted by Helen:

A little while ago I was asked to solve this "safe cracker" puzzle, a sweet example of a coffee table puzzle. The basic gist of this puzzle is that it contains 4 concentric circles with 16 radial sections each containing a number. However, the 3 inner concentric circles have movable components which cover every second number with another. The puzzle is solved when the 4 numbers in each and every radial section sum to 40. I have attached pictures which will hopefully make this clearer.

I wrote some code in Mathematica (shown below) which dramatically reduced the number of possible solutions and from this I was able to "crack" the puzzle, however the first rather inelegant step was to manually type in every number that occurs in each concentric circle, on both the stationary and movable parts.

circle1 = {2, 15, 23, 19, 3, 2, 3, 27, 20, 11, 27, 10, 19, 10, 13, 10}
circle2 = {17, 9, 2, 10, 2, 1, 10, 2, 15, 9, 6, 3, 9, 24, 16, 9, 22, 5, 5, 24, 10, 7, 12, 10}
circle3 = {10, 14, 2, 5, 22, 8, 2, 8, 17, 6, 15, 22, 14, 1, 5, 11, 27,5, 7, 24, 3, 15, 6, 1}
circle4 = {3, 10, 6, 6, 6, 13, 2, 3, 10, 3, 1, 6, 5, 10, 8, 10, 1, 10,10, 6, 4, 5, 4, 6}
i = 1; j = 1; k = 1; l = 1
combs = Table[{circle1[[i]], circle2[[j]], circle3[[k]], circle4[[l]]}, {i, 1, 16}, {j, 1, 24}, {k, 1, 24}, {l, 1, 24}]
list = Table[Total[Flatten[combs[[1]], 2][[i]]], {i, 1, Length[Flatten[combs[[1]], 2]]}]
Drop[Extract[Flatten[combs[[1]], 2], Position[list, 40]], {1, -1, 2}]


I would like to be able to simply take pictures of the safe cracker and use text recognition to read the numbers straight into my code, however the orientation of the numbers on the puzzle makes it not possible to do in a simple way. It seems to me that the image would have to be manipulated in order that the numbers on each of the concentric circles could be read as a straight line. I was wondering if anyone had any ideas of how this could be done?

• your actual question seems to have little to do with the puzzle, you just want to extract the numbers from the image (right?). I'd suggest you work on a better title, and show what you have tried. Commented Nov 7, 2016 at 14:56
• Actually I want the best way or lets say the non-linear(creative) way to solve both the Recognition and the Mathematical facets of this Puzzle ^^..good luck @george2079 Commented Nov 7, 2016 at 15:48
• you have I think two interesting questions, you should pose it as two separate questions. As to the puzzle, I'd think you would want to start with 7 lists, keeping the moving and stationary parts separate. Commented Nov 7, 2016 at 16:26
• Here's a link to the original post of this problem, which gives some image processing ideas: community.wolfram.com/groups/-/m/t/573559 I was the original poster of this and I think it better to link the two so people can see suggestions from the original. As you can see, some answers to this challenge already exist on this forum. This isn't just a similar question but rather a complete copy-paste of my post, but under someone else's name. The text, pictures and code are identical. I think it'd have been more useful if @Youphyso had just commented on the original post in the first place. Commented Nov 11, 2016 at 10:06
• I am sorry for not being so clear in crediting this post,I thought the first line which asserts that this is from the wolfram community would be sufficient,I posted it here because I wanted the ingenious users of this forum to attack this problem,especially the Image processing part. Commented Nov 12, 2016 at 19:14

a solution to the puzzle: consider each of the 4 wheels as a 16x4 matrix with zeros for all of the "open" or "always covered" areas:

wheel1 = {
{2, 15, 23, 19, 3, 2, 3, 27, 20, 11, 27, 10, 19, 10, 13, 10},
{22, 9, 5, 10, 5, 1, 24, 2, 10, 9, 7, 3, 12, 24, 10, 9},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
wheel2 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{2, 0, 10, 0, 15, 0, 6, 0, 9, 0, 16, 0, 17, 0, 2, 0},
{8, 24, 8, 3, 6, 15, 22, 6, 1, 1, 11, 27, 14, 5, 5, 7},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
wheel3 =
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 5, 0, 10, 0, 2, 0, 22, 0, 2, 0, 17, 0, 15, 0, 14},
{8, 6, 3, 1, 6, 10, 6, 10, 2, 6, 10, 4, 1, 5, 5, 4}};
wheel4 =
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 10, 0, 10, 0, 6, 0, 13, 0, 3, 0, 3, 0, 6, 0, 10}};


then assemble a puzzle in any configuration by rotating and assembling the matrices:

config[{a4_, a3_, a2_}] :=
First@Cases[{##}, i_ /; i > 0] &, {
RotateLeft[wheel4, {0, a4}],
RotateLeft[wheel3, {0, a3}],
RotateLeft[wheel2, {0, a2}], wheel1}, 2]


The configurations in the two images are:

config[{0, 0, 0}] // MatrixForm
config[{15, 2, 1}] // MatrixForm


There are only 16^3 configuration, so try all:

sol = First /@
Select[{##, Total /@ Transpose[config[#]]} & /@
Tuples[Range[0, 15], 3], Union@#[[2]] == {40} &];
(result = config[sol[[1]]]) // MatrixForm


 Total /@ Transpose[result]


{40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40}

I'll add if someone was after an efficient algorithm to solve this "by hand" note that that the overall total must be 16*40=640. Moving each wheel 2 spots reveals the same numbers, so there are only 8 possible overall totals, only one of which is 640. Working out those 8 cases reveals that each wheel position is determined Mod[2], and importantly the exposed numbers on the second ring of the base must be {9,10,1,2,9,3,24,9}. Once there, there are only 8^2=64 ways to position the inner two wheels which one could easily work through manually turning the wheels.

• Thank you @george2079 for this gorgeous detailed solution of the mathematical side of the puzzle. Commented Nov 9, 2016 at 20:27
• We wait for the ImageProcessing solvers like @Nike ^^ Commented Nov 9, 2016 at 21:26
• really, i'm waiting to see the image processing solution too! Commented Nov 9, 2016 at 21:53

The question, originally posted by Helen Shiells and copy pasted here without credit, is about image processing for text recognition rather than actually computing the answer. george2079's answer is actually for an entirely different question.

The original link (found here: http://community.wolfram.com/groups/-/m/t/573559) already has some ideas of how to go about doing this.

David Gathercole provides the start of a method to identify symbols and rotate them to improve text recognition (notebook attached in the original link)

Vitaliy Kaurov then goes on to provide a starting point for using machine learning to train a digit recognizer (again all in the original link with further links to useable examples)

A combination of image manipulation (to aid text recognition) and machine learning (to aid accuracy) should be able to solve the problem.

• This is fine as a comment, but not really appropriate as an answer. Commented Nov 11, 2016 at 17:19
• Why is it not appropriate as an answer? The question states that they would like to use text recognition on photos but that the orientation of the symbols is problematic. The answer provided points to a pre-existing method to resolve orientation and then goes on to mention how text recognition could be improved. Perhaps I should pull more of the existing information from the OP into the the answer? Commented Nov 11, 2016 at 20:24
• An answer should have code in the body of the answer which solves the problem, or at least provides a basic set up to do so. Commented Nov 11, 2016 at 20:55
• I do not believe there's any specific requirement that an answer must include code. However, I will try and pull some more information out of the OP and bring it into my answer as that will be useful for anyone that comes across it. Commented Nov 11, 2016 at 21:16

This is the solution for the original puzzle THE GREAT ZUCCHINI BURGLAR PUZZLE patent May 1911. It is the same puzzle but the number positions from 1-16 are different. But each sequence of numbers is correct.

1. 2,6,22,10 next numbers to its right
2. 10,9,15,6
3. 15,9,6,10
4. 13,15,2,10
5. 10,3,24,3
6. 19,10,10,1
7. 10,3,24,3
8. 27,2,5,6
9. 11,9,7,13
10. 20,12,4,4
11. 27,2,5,6
12. 3,17,15,5
13. 2,1,27,10
14. 3,16,17,4
15. 19,10,1,10
16. 23,9,2,6

Continue to work with the right (clockwise) set of numbers until you make it to the 16th answer. I hope this helps someone.

• How did you arrive at this answer? Commented Oct 28, 2021 at 23:58
• I read a tip from someone saying that they started working with one set of numbers at a time and it wasn’t working. It wasn’t until they worked on a group of numbers at a time and as a process of elimination it became easier and easier so I did what they did and I solved it. I kept winding the wheels back and forth while doing it. You have to be patient though and you can solve it. Good luck!
– E M
Commented Oct 29, 2021 at 1:19
• I’m sorry guys out there for the confusion but I own the Red, White, and Blue The Great Zucchini Burglar Puzzle. So the order in this one may indeed be correct. I erroneously thought they were identical. It wasn’t until I compared the image to my puzzle that I realized they were different. So sorry about this, my apologies!
– E M
Commented Oct 29, 2021 at 14:59