Games and puzzles
|
Consider:
Logic activities Mastermind ... Guess the 4 random colors selected by the program. Putting too many colors (and the responses) in play too early makes it very difficult to organize a scheme for drilling down to the answer. Set Game ... Exercises both halves of the brain: the logical hemisphere (analytical thinking), and the holistic thinking hemisphere (perceive and interpret complex patterns). Given 12 cards: find a set of 3 cards that satisfy the criteria of a set across 4 dimensions (number, color, shape, and fill). Peg Game ... Jump and remove pegs until one peg remains. The program evaluates each requested jump, and does not allow a jump that would result in more than one peg remaining when all possible jumps have been exhausted. Decrypt ... Recover the original quote by identifying how each letter in the cipher stands for another. Towers of Hanoi ... Move 5 disks from the first peg to the third peg by: moving one disk at a time, and never putting a larger disk on top of a smaller disk. Grid Game ... Find the target in a 10x10 grid. A very simple game that is remarkably engaging. | ![]()
Input: 1 1 2 2 2 1 Input: 4 4 6 6 1 0 Input: 1 4 1 2 1 1 Input: 2 1 6 2 4 0 |
Mastermind ... A GUI is hard, but a command line interface (using digits 1 through 6) is very straight-forward (above and to the right). Computing the "totally correct" response is easy. Computing the "partially correct" response may seem too advanced for the beginner; but I propose it is an interesting algorithm puzzle.
Cracker Barrel Peg Game ... How should jump requests be validated and implemented? Is it algorithm, or data structure, or both?
Alphametics (solving addition problems where numbers have been replaced with letters) ... How would you solve this puzzle with pseudocode? Is it reasonable to address this puzzle by evaluating all possible combinations or permutations? Which is needed: combinations or permutations? What is the formula for computing the total number of combinations/permutations?
Set Game ... Algorithm: how to decide whether 3 cards constitute a set. Algorithm: how to compute all the sets present in an array of 12 cards. Is it reasonable to evaluate all combinations (or permutations?) of 12 cards taken 3 at a time?
Decrypt ... Design the data structure(s) and layer(s) of indirection that make the encryption and lookup straight-forward.
Fifteen Puzzle, Towers of Hanoi, and Grid Game are fairly ambitious with a GUI **but** they are very straight-forward with a command line interface.
![]() Fifteen Puzzle | ||||
Introductory opportunities | Data structure opportunities | Algorithm opportunities | ||
---|---|---|---|---|
cout and a loop to print a rowstd::setw() to right-justify numbers |
|
| ||
![]() Mastermind | ||||
Introductory opportunities | Data structure opportunities | Algorithm opportunities | ||
cout and cin to prompt for and receive
input |
data structures that are necessary |
| ||
![]() Grid Game | ||||
Introductory opportunities | Data structure opportunities | Algorithm opportunities | ||
cout and loops to print the boardstd::setw() to right-justifysprintf to perform integer-to-string conversionstringstream to perform integer-to-string conversionvector to replace arraysclass to encapsulate the puzzle engine
|
|
| ||
![]() Peg Game | ||||
Introductory opportunities | Data structure opportunities | Algorithm opportunities | ||
cout and a loop to print the boardcout and cin to prompt for and receive input
|
|
| ||
![]() Set Game | ||||
Introductory opportunities | Data structure opportunities | Algorithm opportunities | ||
|
|
| ||
![]() Alphametics | ||||
Introductory opportunities | Data structure opportunities | Algorithm opportunities | ||
map new next_permutation()
| map that holds the association between a character and its
corresponding position in an integer array that represents the current
guess
| is_guess_valid() get_value_for_word() print_word()
| ||
![]() Towers of Hanoi | ||||
Introductory opportunities | Data structure opportunities | Algorithm opportunities | ||
|
|
with a "DOS command line" user interface |