diff options
| author | Dave Jacoby <jacoby.david@gmail.com> | 2021-08-11 16:19:43 -0400 |
|---|---|---|
| committer | Dave Jacoby <jacoby.david@gmail.com> | 2021-08-11 16:19:43 -0400 |
| commit | 989dcde471a30935b8e51c557b971496963caffc (patch) | |
| tree | 1f10f411a03e3348f5b8cd30035770e989349c09 | |
| parent | c52d22f3dd5bedae54a26983bfe372a75bf54500 (diff) | |
| download | perlweeklychallenge-club-989dcde471a30935b8e51c557b971496963caffc.tar.gz perlweeklychallenge-club-989dcde471a30935b8e51c557b971496963caffc.tar.bz2 perlweeklychallenge-club-989dcde471a30935b8e51c557b971496963caffc.zip | |
Edges, Not Nodes
| -rw-r--r-- | challenge-125/dave-jacoby/perl/ch-1.pl | 18 | ||||
| -rw-r--r-- | challenge-125/dave-jacoby/perl/ch-2.pl | 4 |
2 files changed, 3 insertions, 19 deletions
diff --git a/challenge-125/dave-jacoby/perl/ch-1.pl b/challenge-125/dave-jacoby/perl/ch-1.pl index 717d608a68..29f99b60d3 100644 --- a/challenge-125/dave-jacoby/perl/ch-1.pl +++ b/challenge-125/dave-jacoby/perl/ch-1.pl @@ -65,22 +65,4 @@ sub pt_c ($n ) { } return uniq @output if @output; return undef; - - # my @output; - # my $n2 = $n**2; - - # for my $a1 ( 1 .. $n2 ) { - # my $a2 = $a1**2; - # for my $b1 ( 1 .. $n2 ) { - # my $b2 = $b1**2; - # my $c2 = $a2 + $b2; - # next if $c2 > $n2; - # if ( $n2 == $c2 ) { - # my @x = sort { $a <=> $b } map { int $_ } $a1, $b1, $n; - # push @output, $json->encode( \@x ); - # } - # } - # } - # return uniq @output if @output; - # return undef; } diff --git a/challenge-125/dave-jacoby/perl/ch-2.pl b/challenge-125/dave-jacoby/perl/ch-2.pl index b6e5e97817..8dd5fb4268 100644 --- a/challenge-125/dave-jacoby/perl/ch-2.pl +++ b/challenge-125/dave-jacoby/perl/ch-2.pl @@ -47,7 +47,9 @@ my $done; grep { scalar $_->@* == $max } sort { scalar $b->@* <=> scalar $a->@* } @diameters; -say join "\n", map { join " ", ( scalar $_->@* ), ':', $_->@* } +# DIAMETER refers to the edge count, not the node count, +# so the it's the node count minus one +say join "\n", map { join " ", ( -1 + scalar $_->@* ), ':', $_->@* } @diameters; |
