The Domino Effect

A standard set of Double Six dominoes contains 28 pieces (called bones) each displaying two numbers from 0 (blank) to 6 using dice-like pips. The 28 bones, which are unique, consist of the following combinations of pips: Bone # Pips 1 0|0 2 0|1 3 0|2 4 0|3 5 0|4 6 0|5 7 0|6 Bone # Pips 8 1|1 9 1|2 10 1|3 11 1|4 12 1|5 13 1|6 14 2|2 Bone # Pips 15 2|3 16 2|4 17 2|5 18 2|6 19 3|3 20 3|4 21 3|5 Bone # Pips 223|6 234|4 244|5 254|6 265|5 275|6 286|6 All the Double Six dominoes in a set can he laid out to display a 7 × 8 grid of pips. Each layout corresponds at least one “map” of the dominoes. A map consists of an identical 7 × 8 grid with the appropriate bone numbers substituted for the pip numbers appearing on that bone. An example of a 7 × 8 grid display of pips and a corresponding map of bone numbers is shown below. 7 x 8 grid of pips 66265241 13201034 13246654 10432112 51360455 55402603 60534203 map of bone numbers 282814 717171111 101014 7 2 22123 8 4162525132123 8 416151513 9 9 12122222 5 52626 272424 3 318 119 27 6 6202018 119 Write a program that will analyze the pattern of pips in any 7×8 layout of a standard set of dominoes and produce a map showing the position of all dominoes in the set. If more than one arrangement of dominoes yield the same pattern, your program should generate a map of each possible layout. Input The input file will contain several of problem sets. Each set consists of seven lines of eight integers from 0 through 6, representing an observed pattern of pips. Each set is corresponds to a legitimate configuration of bones (there will be at least one map possible for each problem set). There is no intervening data separating the problem sets. Output Correct output consists of a problem set label (beginning with Set #1) followed by an echo printing of the problem set itself. This is followed by a map label for the set and the map(s) which correspond to the problem set. (Multiple maps can be output in any order.) After all maps for a problem set have been printed, a summary line stating the number of possible maps appears.

2/3 At least three lines are skipped between the output from different problem sets while at least one line separates the labels, echo printing, and maps within the same problem set. Note: A sample input file of two problem sets along with the correct output are shown. Sample Input 54365346 06012311 32650420 53623206 40410041 52244165 55361231 42526354 50431411 12302222 14013565 40603665 40164030 65362153 Sample Output Layout #1: 54365346 06012311 32650420 53623206 40410041 52244165 55361231 Maps resulting from layout #1 are: 6 20 20 27 27 19 25 25 6 18 2 2 3 19 8 8 21 182817 3 16 16 7 21 4 28 17 15 15 5 7 24 4 11 11 1 1 5 12 24 14 14 23 23 13 13 12 26 262222 9 9 10 10 There are 1 solution(s) for layout #1. Layout #2: 42526354 50431411 12302222

3/3 14013565 40603665 40164030 65362153 Maps resulting from layout #2 are: 16 16 24 18 18 20 12 11 6 6 24 10 10 20 12 11 8 15 15 3 3 17 14 14 2 19 17 28 26 2 19 728 26 8 5 5 23 1 13 23 1 13 25 25 7 4 4 27 27 22 22 9 921 21 16 16 24 18 18 20 12 11 6 6 24 10 10 20 12 11 8 15 15 3 3 17 14 14 8 23 23 27 5 5 1 13 1 13 27 22 There are 2 solution(s) for layout #2. 2 19 17 28 26 2 19 25 25 22 9 728 26 721 4 921 4