<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font face="Helvetica, Arial, sans-serif">I'm calling this one
advanced because it might be time intensive in Perl 6 (bait set).
I'll publish an easier assignment in a couple days or so. This is
a variation on an old riddle.<br>
<br>
Tackle one part or all parts of this problem in Perl or Perl 6.
The only argument to your program is a single integer,
representing the number of members in your traveling party.<br>
<br>
With a group of any random number of members, no less than 3,
represented by exactly three <i><b>types</b></i> of members,
design the most efficient algorithm that gets each member safely
from one side of a Bifröst bridge to the other.</font><br>
<font face="Helvetica, Arial, sans-serif"><br>
The laws of probability apply in the distribution of types to
members. You have to create the type-assignment mechanism that
properly determines types based on these laws. The only violation
of this principle is that there must be at least one member of
each type present. Once you've determined your types, you start
crossing your members over the bridge.</font><font
face="Helvetica, Arial, sans-serif"> This is a problem in and of
itself.<br>
<br>
One member may cross at a time, because the way is dark, narrow,
and only wide enough for 1 guide and 1 traveler to pass at a
time. You are the guide, you hold Mjölnir, and no one crosses
without you. Traveling members can never get across unaided.<br>
<br>
Let (d) stand for duration.<br>
Traveling member type one (Fortran programmer) is slow and
withered with age. It takes this member 3d time to cross the </font><font
face="Helvetica, Arial, sans-serif"><font face="Helvetica, Arial,
sans-serif">Bifröst<br>
</font>Type two (mouse) is faster than the others and can cross in
1d time<br>
Type three (cat) crosses in 2d</font> <font face="Helvetica,
Arial, sans-serif">and poses a danger to type two travelers if
left unsupervised with them on the FAR SIDE of the bridge. On the
near side, Heimdallr is guarding the mice.<br>
You are allowed to "sacrifice" some of your members to this
danger. Leaving one cat on the far side with any number of mice
results in a (m) mortality.<br>
A cat will only kill once.<br>
A mortality incurs a duration penalty equal to the (d) value of
the member that was sacrificed, because a proper viking burial
will have to be carried out for the fallen warrior, resulting in
heavy hearts, and more delay.<br>
<br>
The winning algorithm will do this in the lowest (d) duration time
and with the lowest (m) mortality rate. The type-assignment and
bridge-crossing algorithms must be correct.<br>
<br>
Expected input: 100 (suggested starting point)<br>
<br>
Expected output:<br>
<br>
Total Fortran programmer duration: __d<br>
Total Cat duration: __d<br>
Total Mouse duration: __d<br>
Total traveler duration: __d<br>
<br>
You can add statistics about which category took up the most time,
etc. It's all for fun. The answer could be ridiculously easy.<br>
<br>
-- <br>
Tommy Butler<br>
</font>
</body>
</html>