Problem Description
The task here is to divide the displayed grid into two identically
shaped pieces so that one piece contains all the pre-placed P's
and the other piece contains all the pre-placed Q's.
Background & Techniques
Another calendar puzzle that is well suited to at least using the computer as
a helper.
In the days of hand-set type, print shop apprentices frequently confused the
letters "p" and "q" because while all letters appear on the type pieces as
mirror images, it happens that these two letters are also mirror images of each
other, making it easy to interchange them when setting type. Thus the warning
"Mind your p's and q's!" today expanded to mean "Pay attention to the details!"
The two pieces required to solve this puzzle will not only be mirror imaged
(flipped about its vertical axis),
but also reversed to top bottom (flipped about its horizontal axis).
Interestingly, and perhaps a clue to help solving these puzzles, these two flips
are equivalent to a 180 degree rotation.
Only two puzzles of this type have been found so far and have been included
in the download zip files below. , New puzzles however, can be entered by
keying in the size of the grid and the column and row locations of the
pre-placed Pa and Qs. Puzzles may also be saved and reloaded.
Rather drawing heavy outlines, the two pieces are defined by assigning a
color to each of the two letters and assigning colors to other grid cells by
clicking Click blank squares to create two patterns of the same
shape. Clicking a blank square will fill it with the current Default color.
Clicking the Default square or a colored grid square will swap colors in that
square and set the Default color to the new color.
A "Congratulations" message will be displayed when the puzzle has been
solved.
Non-programmers are welcome to read on, but may want to jump to bottom of
this page to download the executable program now.
Programmer's Notes:
A StringGrid is used to display the puzzle. Since the grid cell colors
are changed by clicking and must be capable of being redrawn at any time, I used
2 character strings to control cell appearance. The first character
contains indicates color ("1" for P color, "2" for Q color and a space character
for the empty grid color. The second character in the string indicates the
character to be displayed ("P", "Q" is space). A MousUp event exit
sets cell values and a StringGrid DrawCell event exit draws the cell with the
color and character indicated by the cell's contents.
The other significant piece of code check for solution checks for a solution
by checking if each cell has the opposite color as the cell at the same distance
from the bottom-right corner as this cell is from the top-left corner. I
haven't yet proved that all puzzles must meet this condition, but it is true for
the samples I have found, Any samples I have constructed which do not fit this
rule are trivial. .
Running/Exploring the Program