PUZZLES
MATLAB Programs Useful for Puzzles


PUZZLES is a directory of MATLAB programs which were used to solve puzzles.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

PUZZLES is available in a FORTRAN90 version and a MATLAB version.

Related Programs:

ANAGRAM, a C++ program which determines anagrams of a string, by James Cherry;

LIFE_OPENGL, a C program which uses OpenGL to display the evolution of John Conway's "Game of Life", by Simon Green.

LIGHTS_OUT_OPENGL, a C++ program which sets up a "Lights Out" game and allows the user to solve it, using the OpenGL graphics window.

SUBANAGRAM, a FORTRAN90 program which finds words which are anagrams formed from some of the letters of a given master word.

SUDOKU, a MATLAB library which manipulates and solves Sudoku problems.

WORDSNAKE, a FORTRAN90 program which rearranges a list of words so that they have maximum overlap;


DIGIT PUZZLE

The seven digit puzzle The Digit Puzzle. It wasn't hard to find the seven unique digits of an integer such that the integer was divisible by each digit. But it was actually hard to figure out the order of the digits in the integer! Some thought was able to whittle down the last few digits to a small collection, and we knew the integer had to be a multiple of the least common multiple of the digits, but no way was obvious to actually determine the integer. At that point, Jeff Borggaard wrote the following MATLAB program to search for the answer.


PERMUTATION PUZZLE

Let P1 and P2 be arbitrary permutations of the integers from 1 to 10.

Pair corresponding entries of the permutations to create the set of 10 points (P1(1),P2(1)) through (P1(10),P2(10)). Now subtract 5, that is, N/2, from the X and Y coordinates of each point so that their average value is zero. Then apply a rotation of 45 degrees to each vector.

Now instead of looking at 10 vectors (X(I),Y(I)), each of length 2, consider the data as two vectors X and Y, each of length 10. If the instructions have been followed correctly, then X are Y are perpendicular to each other in 10-dimensional space.

MATLAB code to verify a random example of this property is:

         n = 10;
         p1 = randperm ( n );
         p2 = randperm ( n );
         xy = [ p1; p2 ];
         xy = xy - ( n / 2 );
         angle = pi / 4;
         A = [ cos ( angle ), - sin ( angle ); ...
               sin ( angle ),   cos ( angle ) ];
         xy = A * xy;
         dot = xy(1,1:n) * xy(2,1:n)';
         fprintf ( 1, '  The dot product is %f\n', dot );
       

Claim: This property is true for any pair of permutations P1 and P2.

Claim: This property is true even if P1 and P2 are equal.

Claim: This property is true for any positive integer N.

Claim: This property is not true for arbitrary values of the rotation angle. For instance, using an angle of pi/3 will not work.

Claim: Let Q be an arbitary vector of length N. Instead of P1 and P2, consider the vectors Q1=Q(P1) and Q2=Q(P2). The property is still true!

Puzzle: Can you verify that each of the claims is true? Can you explain why?


Last revised on 12 September 2009.