Shlomi Fish avatar Shlomi Fish committed 65d36e5

Working now.

Comments (0)

Files changed (2)

project-euler/86/euler-86-analysis.txt

+If C >= B >= A, prove that A^2 + (B+C)^2 > B^2 + (C+A)^2 and that
+A^2 + (C+B)^2 > C^2 + (B+A)^2 .
+
+C^2 + (B+A)^2 = C^2 + B^2 + A^2 + 2BA, so the maximum is when BA is maximal,
+so we need to pick up B and C. Likewise, the minimum is when we take C in 
+separate from A and B.
+

project-euler/86/euler-86.pl

     {
         for my $L (1 .. $N)
         {
-            my @arr = ($M,$N,$L);
-            my $get_dist = sub {
-                my $idx = shift;
-                my $x = $arr[$idx];
-                my $t = $arr[($idx+1)%3] + $arr[($idx+2)%3];
-                return ($x*$x+$t*$t);
-            };
-            my $dist_sq = min(map { $get_dist->($_) } (0 .. $#arr));
+            # my @arr = ($M,$N,$L);
+            # my $get_dist = sub {
+            #     my $idx = shift;
+            #     my $x = $arr[$idx];
+            #     my $t = $arr[($idx+1)%3] + $arr[($idx+2)%3];
+            #     return ($x*$x+$t*$t);
+            # };
+            # print join(',',map { $get_dist->($_) } (0 .. $#arr)), "\n";
+            # my $dist_sq = min(map { $get_dist->($_) } (0 .. $#arr));
+            my $dist_sq = $M * $M + ($N+$L) ** 2;
             my $dist = sqrt($dist_sq);
             if (int($dist) == $dist)
             {
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.