puzzles


puzzles, a MATLAB code which was 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:

sudoku, a MATLAB code which manipulates and solves Sudoku problems.

Reference:


CASINO PUZZLE

A casino offers a game in which, each time you play, a fair coin is flipped. On heads, your stake is increased by 20%, and on tails, decreased by 17%. Is this a fair game? On average, can you expect to increase your stake by 3%?

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 code 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 10 November 2019.