<!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.2654.45">
<TITLE>Puzzle: 100 Monkeys</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 100 Monkeys</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2003-01-14</FONT>
</P>

<P><FONT SIZE=2>Note: This puzzle came to me unattributed by way of a </FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; co-worker. If anyone chances by the source, please</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let me know so I can give credit.</FONT>
</P>

<P><FONT SIZE=2>There are 100 doors, all closed.&nbsp; In a nearby cage are 100</FONT>
<BR><FONT SIZE=2>monkeys.&nbsp; The first monkey is let out, and runs along the</FONT>
<BR><FONT SIZE=2>doors opening every one.&nbsp; The second monkey is then let out,</FONT>
<BR><FONT SIZE=2>and runs along the doors closing the 2nd, 4th, 6th,...&nbsp; all</FONT>
<BR><FONT SIZE=2>the even-numbered doors.&nbsp; The third monkey is let out.&nbsp; He</FONT>
<BR><FONT SIZE=2>attends only to the 3rd, 6th, 9th,... doors (every third</FONT>
<BR><FONT SIZE=2>door, in other words), closing any that is open and opening</FONT>
<BR><FONT SIZE=2>any that is closed.&nbsp; The fourth monkey does the same for the</FONT>
<BR><FONT SIZE=2>4th, 8th, 12th, 16th,... doors, opening the closed ones and</FONT>
<BR><FONT SIZE=2>closing the open ones.&nbsp; The fifth monkey does the same to</FONT>
<BR><FONT SIZE=2>the 5th, 10th, 15th,... doors, and so on.&nbsp; After all 100</FONT>
<BR><FONT SIZE=2>monkeys have done their work in this way, which doors are</FONT>
<BR><FONT SIZE=2>left open?</FONT>
</P>

<P><FONT SIZE=2>Format:&nbsp;&nbsp; m/^\d+(?:\s\d+)*$/ # scalar must match this regex</FONT>
</P>

<P><FONT SIZE=2>Goal:&nbsp;&nbsp;&nbsp;&nbsp; fastest script to calculate the answer</FONT>
</P>

<P><FONT SIZE=2>Prize:&nbsp;&nbsp;&nbsp; Your choice of O'Reilly's</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp; Perl in a Nutshell, 2nd Edition</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; o&nbsp; Creating Applications with Mozilla</FONT>
</P>

<P><FONT SIZE=2>Deadline: Answers must be submitted at least 24 hours</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; before the next kc.pm meeting (February 11th)</FONT>
</P>

<P><FONT SIZE=2>--</FONT>
<BR><FONT SIZE=2>Garrett Goebel</FONT>
<BR><FONT SIZE=2>IS Development Specialist</FONT>
</P>

<P><FONT SIZE=2>ScriptPro&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Direct: 913.403.5261</FONT>
<BR><FONT SIZE=2>5828 Reeds Road&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Main: 913.384.1008</FONT>
<BR><FONT SIZE=2>Mission, KS 66202&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fax: 913.384.2180</FONT>
<BR><FONT SIZE=2>www.scriptpro.com&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; garrett@scriptpro.com</FONT>
</P>

<P><FONT SIZE=2>&nbsp;</FONT>
</P>

</BODY>
</HTML>