Richard Proctor <Richard@waveney.org> wrote: > This looks a fun game... Here is my initial offering (at 181 - not yet > down to APL). > > for$s(@s=qw/S H D C/){for(split//,"AKQJT98765432"){ > redo if++$t[$h=3&rand 4]>13;${$s.$h}.=$_}}; > for(0..2){for$s(@s){ > printf$_&1?("$s: %-21s",${$s.3}):" "x12;print"$s: ".${$s.$_}."\n"}} Down to 173 with some trivial changes: for$s(@s=(S,H,D,C)){for(split//,AKQJT98765432){ redo if++$t[$h=3&rand 4]>13;${$s.$h}.=$_}} for(0..2){for$s(@s){ printf$_&1?("$s: %-21s",${$s.3}):$"x12;print"$s: ".${$s.$_}.$/}} But I still don't think the method of distributing cards is right. Like Rick Delaney, you're going through one suit at a time and distributing each card to a random player. You've added a check to make sure you no player gets more than 13 cards, so the difference from a real deal is more subtle, but it's still there. As the cards are distributed in order, consider what happens as players' hands start to fill up. The clubs (which come last) will be distributed strangely; the most obvious problem is that the 2 and 3 of clubs are too likely to go to the same person. If there's a way to simulate a deal by handling one suit at a time, it's got to be more complicated than this. (You're also missing the blank lines that were in the original example, but that may not be important.) My earlier attempt has evolved from 239 to 218: @d='00'..51;$t=($"x@d.$/)x14;@p=(13,265,289,543);for$p(@p){ @h=sort+map{splice@d,rand@d,1}a..n;for$s(S,H,D,C){substr$t, $p,2,"$s:";int$_/13==$i%4&&substr($t,$p+3)=~s/ /(2..9,T,J,Q ,K,A)[12-$_%13]/efor@h;$p+=53;$i++}}die$t I got it to 213, except that I lost the spaces after the colons in the output: @d='00'..51;$t=($"x@d.$/)x14;@p=(13,265,289,543);for$p(@p){ @h=sort+map{splice@d,rand@d,1}a..n;for$s(S,H,D,C){*_=\substr $t,$p;s/../$s:/;for$h(@h){int$h/13==$i%4&&s/ /(2..9,T,J,Q,K, A)[12-$h%13]/e};$p+=53;$i++}}die$t But it'll probably take a completely different approach to get below 200. By the way, has anyone found this mythical APL program? -- Keith C. Ivey <kcivey@cpcug.org> Washington, DC ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe