Commits

Shlomi Fish committed 708ffe6

Fix bug

Comments (0)

Files changed (1)

project-euler/152/euler-152-take3.pl

 
 calc_stuff();
 
+=begin Removed
+
 # Deduced by semi-manual deduction.
 @keys = @keys[grep { $ints[$_] % 100 == 0 } keys(@keys)];
 calc_stuff();
 @keys = @keys[grep { $ints[$_] % 17 != 15 } keys(@keys)];
 calc_stuff();
 
+=end Removed
+
+=cut
+
+my @must_have = (2,3,4,5,6,7,9,10,12,15,20,28,30,35,36,45);
+
+my %must_have_lookup = (map { $_ => 1 } @must_have);
+
 my $found = 1;
 MAIN_TRIM:
 while ($found)
             @keys = @keys[
                 (grep { !exists($not_mods{($ints[$_] % $n).''}) } keys(@keys))
             ];
+            # Sanity check for keys that must be present.
+            if ((grep { exists($must_have_lookup{$_}) } @keys) !=
+                scalar(keys %must_have_lookup))
+            {
+                die "Some keys are missing.";
+            }
             last TRIM_STUFF;
         }
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.