<!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> 100 Monkeys</FONT>
<BR><FONT SIZE=2> 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> co-worker. If anyone chances by the source, please</FONT>
<BR><FONT SIZE=2> let me know so I can give credit.</FONT>
</P>
<P><FONT SIZE=2>There are 100 doors, all closed. In a nearby cage are 100</FONT>
<BR><FONT SIZE=2>monkeys. The first monkey is let out, and runs along the</FONT>
<BR><FONT SIZE=2>doors opening every one. The second monkey is then let out,</FONT>
<BR><FONT SIZE=2>and runs along the doors closing the 2nd, 4th, 6th,... all</FONT>
<BR><FONT SIZE=2>the even-numbered doors. The third monkey is let out. 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. 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. The fifth monkey does the same to</FONT>
<BR><FONT SIZE=2>the 5th, 10th, 15th,... doors, and so on. 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: m/^\d+(?:\s\d+)*$/ # scalar must match this regex</FONT>
</P>
<P><FONT SIZE=2>Goal: fastest script to calculate the answer</FONT>
</P>
<P><FONT SIZE=2>Prize: Your choice of O'Reilly's</FONT>
<BR><FONT SIZE=2> o Perl in a Nutshell, 2nd Edition</FONT>
<BR><FONT SIZE=2> o Creating Applications with Mozilla</FONT>
</P>
<P><FONT SIZE=2>Deadline: Answers must be submitted at least 24 hours</FONT>
<BR><FONT SIZE=2> 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 Direct: 913.403.5261</FONT>
<BR><FONT SIZE=2>5828 Reeds Road Main: 913.384.1008</FONT>
<BR><FONT SIZE=2>Mission, KS 66202 Fax: 913.384.2180</FONT>
<BR><FONT SIZE=2>www.scriptpro.com garrett@scriptpro.com</FONT>
</P>
<P><FONT SIZE=2> </FONT>
</P>
</BODY>
</HTML>