6
$\begingroup$

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?

enter image description here

enter image description here

$\endgroup$
  • 2
    $\begingroup$ 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. $\endgroup$ – george2079 Nov 7 '16 at 14:56
  • 1
    $\begingroup$ 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 $\endgroup$ – Youphyso Nov 7 '16 at 15:48
  • 4
    $\begingroup$ 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. $\endgroup$ – george2079 Nov 7 '16 at 16:26
  • 2
    $\begingroup$ 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. $\endgroup$ – Helen Nov 11 '16 at 10:06
  • 1
    $\begingroup$ 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. $\endgroup$ – Youphyso Nov 12 '16 at 19:14
10
$\begingroup$

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_}] :=
 MapThread[
  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

enter image description here

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

enter image description here

 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.

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

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.

$\endgroup$
  • 1
    $\begingroup$ This is fine as a comment, but not really appropriate as an answer. $\endgroup$ – Feyre Nov 11 '16 at 17:19
  • $\begingroup$ 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? $\endgroup$ – Hobsie Nov 11 '16 at 20:24
  • 1
    $\begingroup$ 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. $\endgroup$ – Feyre Nov 11 '16 at 20:55
  • $\begingroup$ 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. $\endgroup$ – Hobsie Nov 11 '16 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.