1. Shlomi Fish
  2. project-euler

Commits

Shlomi Fish  committed 9700251

An optimisation by inspiration from a forum post.

To euler #90.

  • Participants
  • Parent commits 19ed866
  • Branches default

Comments (0)

Files changed (1)

File project-euler/90/euler-90.pl

View file
 
 my $max_digit = 9;
 
+my $loop_limit = $max_digit-6;
+
 my %die_combs =
 (
     1 => [qw(0 1 2 3 4 5 6 7 8 9)],
         return recurse_die2(get_regex(1, $indices), [0]);
     }
     
-    foreach my $next_idx ($indices->[-1]+1 .. $max_digit)
+    foreach my $next_idx ($indices->[-1]+1 .. ($loop_limit + @$indices))
     {
         recurse_die1([@$indices, $next_idx]);
     }
         return;
     }
         
-    foreach my $next_idx ($indices->[-1]+1 .. $max_digit)
+    foreach my $next_idx ($indices->[-1]+1 .. ($loop_limit + @$indices))
     {
         recurse_die2($reg_comp1, [@$indices, $next_idx]);
     }