Shlomi Fish avatar Shlomi Fish committed c70dea1

Add the rejects.

Comments (0)

Files changed (1)

project-euler/126/rejects.pl

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+=begin foo
+    my $new_layer_count = 0;
+
+    my $calc_dist = sub {
+        my ($x, $x_lim) = @_;
+
+        return
+            (($x < 0) ? abs($x) : ($x >= $x_lim) ? ($x-($x_lim-1)) : 0);
+    };
+
+    foreach my $x (-$depth .. $x_lim+$depth-1)
+    {
+        my $dist_x = $calc_dist->($x,$x_lim);
+
+        foreach my $y (-$depth .. $y_lim + $depth-1)
+        {
+            my $dist_y = $calc_dist->($y,$y_lim);
+
+            foreach my $z (-$depth .. $z_lim + $depth-1)
+            {
+                my $dist_z = $calc_dist->($z, $z_lim);
+
+                if ($dist_x+$dist_y+$dist_z == $depth)
+                {
+                    $new_layer_count++;
+                }
+            }
+        }
+    }
+
+    if ($new_layer_count != $expected_new_layer_count)
+    {
+       die "\$new_layer_count != \$expected_new_layer_count ==
+        $new_layer_count != $expected_new_layer_count for depth $depth
+            and ($x_lim,$y_lim,$z_lim).";
+    }
+
+=end foo
+
+=cut
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.