Message Boards Message Boards

10
|
16681 Views
|
4 Replies
|
24 Total Likes
View groups...
Share
Share this post:

"SafeCracker" puzzle - a coffee table challenge

Posted 9 years ago

Hello everyone,

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?

[I have attached a couple of photos which between them show every number on the safe cracker - i.e., in the second picture the movable parts have been adjusted to show the previously hidden numbers.]

Attachments:
POSTED BY: Helen Shiells
4 Replies

Machine learning should definitely help here. Please see this example. It is also in the docs. You can get training data as:

digits = ExampleData[{"MachineLearning", "MNIST"}, "Data"];

or you also can build your own training set.

enter image description here

POSTED BY: Vitaliy Kaurov

At present the heaviest data in the result images are the rotation boundaries. As we know the rotation angle before the images are cut out, one could include a rotation dependent margin and crop the characters square. I expect that's the most significant possible improvement.

It's a mild cop out, but building a custom classifier from the images would definitely give the most reliable match.

POSTED BY: David Gathercole
Posted 9 years ago

That's brilliant, thanks David. I have also had this issue where TextRecognize won't recognise these individual numbers. I tried image rotation (with the individual pictures from your notebook) and it seems to think that "19" is "E":

output = TableForm[Rasterize[#, ImageSize -> {45}] & /@ # & /@ resultImagery]
recog = {}; AppendTo[recog, Table[TextRecognize[ImageRotate[output[[1, 1]][[1]], i]], {i, 6, 7, 0.05}]]

Maybe (as you suggested) a filter of some sort will help.

POSTED BY: Helen Shiells

This is a fun problem. I had a few nice ideas and these rapidly degraded into a notebook.

The concept is to pick out things looking like digits with morphological tools. One can then prune off items too far from the center, and fit the most extreme digits to a circle, constricting the circle to find the inner rings.

filter progression

fitting the first ellipse

The reality of the data isn't so nice. Not only are the rings at angles to the camera, but this angle changes with the vertical element, so different ellipses are required for each tier. I fear not accounting for this z axis drop within each ring is one of several weakness to the solution. I was quite pleased with it. Notebook attached.

output

Attachments:
POSTED BY: David Gathercole
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract