Commits

Shlomi Fish committed 30fc9b6

[205] Finished, but it yields a clearly wrong result.

  • Participants
  • Parent commits b057e32

Comments (0)

Files changed (1)

project-euler/205/euler-205.pl

 use strict;
 use warnings;
 
+use List::MoreUtils qw/firstidx/;
+
 =head1 DESCRIPTION
 
 Dice Game
 
 use Data::Dumper;
 
-print Dumper(\%running_sums);
+# print Dumper(\%running_sums);
+#
+
+my $PIVOT = 4;
+my $OTHER = 6;
+
+my $pivot_sums = $running_sums{$PIVOT};
+my $other_sums = $running_sums{$OTHER};
+
+my $prob_sum = 0;
+foreach my $score (0 .. ($#$pivot_sums-1))
+{
+    my $prob = $pivot_sums->[$score];
+    if ($score > 0)
+    {
+        $prob_sum += $prob * ($other_sums->[-1] - $other_sums->[$score+1]);
+    }
+}
+print "ProbSum == ", $prob_sum, "\n",
+    "Prob = ", $prob_sum/($totals{$PIVOT}*$totals{$OTHER}), "\n";