Permalink
Browse files

Fix #1 by conditional roll subroutine.

  • Loading branch information...
1 parent c55c266 commit 45e025ba36a1d0ef901763bae0d8c54c2eed0353 @xfix xfix committed Dec 1, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 dice.pl
View
@@ -1,8 +1,12 @@
+my &safe-roll = (try { (1..6).pick(4, :replace) })
+ ?? ({ $^a.pick: $^b, :replace })
+ !! ({ $^a.roll: $^b });
+
my $chars-to-roll = 600;
my @count = 0 xx 20;
for ^$chars-to-roll {
- my @a = (^6).map({ [+] (1..6).pick(4, :replace).sort(-*)[^3] }).sort(-*);
+ my @a = (^6).map({ [+] safe-roll(1..6, 4).sort(-*)[^3] }).sort(-*);
for @a { @count[$_]++ };
# say ~@a;
}

0 comments on commit 45e025b

Please sign in to comment.