<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2657.73">
<TITLE>Perl 'Expert' Quiz-of-the-Week #17</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Mark Jason Dominus [<A HREF="mailto:mjd@plover.com">mailto:mjd@plover.com</A>] </FONT>
<BR><FONT SIZE=2>Sent: Wednesday, June 02, 2004 6:21 PM</FONT>
<BR><FONT SIZE=2>To: perl-qotw@plover.com</FONT>
<BR><FONT SIZE=2>Subject: Perl 'Expert' Quiz-of-the-Week #17 [x-adr]</FONT>
</P>
<BR>

<P><FONT SIZE=2>IMPORTANT: Please do not post solutions, hints, or other spoilers</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; until at least 60 hours after the date of this message.</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thanks.</FONT>
</P>

<P><FONT SIZE=2>IMPORTANTE: Por favor, no enviéis soluciones, pistas, o cualquier otra</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cosa que pueda echar a perder la resolución del problema hasta</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; que hayan pasado por lo menos 60 horas desde el envío de este</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mensaje. Gracias.</FONT>
</P>

<P><FONT SIZE=2>IMPORTANT: S'il vous plaît, attendez au minimum 60 heures après la</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; date de ce message avant de poster solutions, indices ou autres</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; révélations. Merci.</FONT>
</P>

<P><FONT SIZE=2>WICHTIG: Bitte schicken Sie keine Lösungen, Tipps oder Hinweise für</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; diese Aufgabe vor Ablauf von 60 Stunden nach dem Datum dieser</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Mail. Danke.</FONT>
</P>

<P><FONT SIZE=2>BELANGRIJK: Stuur aub geen oplossingen, hints of andere tips in de</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eerste 60 uur na het verzendingstijdstip van dit</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bericht. Waarvoor dank.</FONT>
</P>

<P><FONT SIZE=2>VNIMANIE: Pozhalujsta ne shlite reshenija, nameki na reshenija, i</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; voobshe lyubye podskazki v techenie po krajnej mere 60 chasov</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ot daty etogo soobshenija.&nbsp; Spasibo.</FONT>
</P>

<P><FONT SIZE=2>Qing3 Zhu4Yi4: Qing3 Ning2 Deng3Dao4 Jie1Dao4 Ben3 Xin4Xi2 Zhi1Hou4 60</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Xiao3Shi2, Zai4 Fa1Biao3 Jie3Da2, Ti2Shi4, Huo4 Qi2Ta1 Hui4</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Xie4Lou4 Da2An4 De5 Jian4Yi4.&nbsp; Xie4Xie4.</FONT>
</P>
<BR>

<P><FONT SIZE=2>----------------------------------------------------------------</FONT>
</P>

<P><FONT SIZE=2>[ ADMINISTRATIVE NOTE:&nbsp; In my report yesterday, I included the wrong</FONT>
<BR><FONT SIZE=2>&nbsp; URL for the example programs.&nbsp; The correct URL is</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF="http://perl.plover.com/qotw/misc/r017/" TARGET="_blank">http://perl.plover.com/qotw/misc/r017/</A></FONT>
</P>

<P><FONT SIZE=2>&nbsp; - MJD. ]</FONT>
</P>

<P><FONT SIZE=2>----------------------------------------------------------------</FONT>
</P>

<P><FONT SIZE=2>[ This isn't the quiz that I planned to send today; there are still</FONT>
<BR><FONT SIZE=2>&nbsp; some kinks we have to work out of that one.&nbsp;&nbsp; Once again I would</FONT>
<BR><FONT SIZE=2>&nbsp; like to encourage people to contribute quizzes or to volunteer to do</FONT>
<BR><FONT SIZE=2>&nbsp; sample solution reports afterwards. Send me mail if you are</FONT>
<BR><FONT SIZE=2>&nbsp; interested.&nbsp; Thanks, -MJD. ]</FONT>
</P>

<P><FONT SIZE=2>Last year my mother-in-law gave me a delightful little puzzle, called &quot;The Sphinx&quot;.&nbsp; It's seven variously shaped wooden tiles, which you try to arrange into various configurations.</FONT></P>

<P><FONT SIZE=2>I did a lot of this kind of puzzle when I was younger; in particular I spent many many hours playing around with pentominoes, which are a set of 12 different-shaped tiles each made by sticking five squares together.&nbsp; Writing a program to solve pentomino puzzles is not hard, because the configuration you're typically trying to achieve has all the pieces aligned with the points of a square grid.&nbsp; The &quot;Sphinx&quot;</FONT></P>

<P><FONT SIZE=2>puzzle was a nice change for me, because the tiles aren't square at all.&nbsp; </FONT>
</P>

<P><FONT SIZE=2>I've illustrated the seven tiles at</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF="http://perl.plover.com/qotw/misc/e017/sph.jpg" TARGET="_blank">http://perl.plover.com/qotw/misc/e017/sph.jpg</A></FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF="http://perl.plover.com/qotw/misc/e017/sph.ps" TARGET="_blank">http://perl.plover.com/qotw/misc/e017/sph.ps</A></FONT>
</P>

<P><FONT SIZE=2>Exact descriptions follow:</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tile&nbsp;&nbsp;&nbsp; Description&nbsp;&nbsp;&nbsp;&nbsp; Angles&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sides&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Area</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Equilateral&nbsp;&nbsp;&nbsp;&nbsp; 60 60 60&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 1 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; triangle</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; B&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Isosceles&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 30 30 120&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Rectangle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 90 90 90 90&nbsp;&nbsp;&nbsp;&nbsp; S 1 S 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp; An &quot;S&quot; in the &quot;Sides&quot; column represents a side with length</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; sqrt(3).&nbsp; The areas in the &quot;Area&quot; column are measured in multiples</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; of tile A, which actually has an area of sqrt(3)/4 square units.</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp; Piece &quot;E&quot; is rather irregular.&nbsp; It is formed by taking a copy of tile</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; C and gluing a copy of tile A to its short side.</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp; Tiles C and D are identical.</FONT>
</P>

<P><FONT SIZE=2>It is permissible to flip the tiles over.&nbsp; And, of course, to rotate them or slide them around on the table.&nbsp; But it is not permitted to overlap them.</FONT></P>

<P><FONT SIZE=2>Your job is to write a program which can solve Sphinx puzzles.&nbsp; The program will be given an input file which describes the configuration that into which the tiles are to be placed.&nbsp; See </FONT></P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF="http://perl.plover.com/qotw/misc/e017/conf.jpg" TARGET="_blank">http://perl.plover.com/qotw/misc/e017/conf.jpg</A></FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF="http://perl.plover.com/qotw/misc/e017/conf.ps" TARGET="_blank">http://perl.plover.com/qotw/misc/e017/conf.ps</A></FONT>
</P>

<P><FONT SIZE=2>for an example.&nbsp; The program should figure out a way to place the tiles into the specified configuration, if there is one, and report the arrangement unambiguously on the output; if no arrangement is possible, it should say so. </FONT></P>

<P><FONT SIZE=2>It's up to you to determine the format of the input and the output.</FONT>
</P>

<P><FONT SIZE=2>The puzzle, by the way, was designed by Nob Yoshigahara, a famous designer of puzzles.&nbsp; The Sphinx puzzle is a little out of his usual line.&nbsp; He specializes in puzzles in which you have to fit a bunch of objects into a container.&nbsp; For example, see</FONT></P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF="http://www.johnrausch.com/PuzzleWorld/puz/pack_the_asparagus.htm" TARGET="_blank">http://www.johnrausch.com/PuzzleWorld/puz/pack_the_asparagus.htm</A></FONT>
</P>

</BODY>
</HTML>