diff options
| author | Kjetil S <kjetilskotheim@gmail.com> | 2021-08-02 12:35:21 +0200 |
|---|---|---|
| committer | Kjetil S <kjetilskotheim@gmail.com> | 2021-08-02 12:35:21 +0200 |
| commit | 16dca877e7a21f4abe938ffc1b39a2f701d8e549 (patch) | |
| tree | c935703fc84e2980f1fefcf588588c90aa3158d1 | |
| parent | 09bad1c034616a6d3ae620b9165adb2f531d14b1 (diff) | |
| download | perlweeklychallenge-club-16dca877e7a21f4abe938ffc1b39a2f701d8e549.tar.gz perlweeklychallenge-club-16dca877e7a21f4abe938ffc1b39a2f701d8e549.tar.bz2 perlweeklychallenge-club-16dca877e7a21f4abe938ffc1b39a2f701d8e549.zip | |
challenge 123: ugly and squared
| -rw-r--r-- | challenge-123/kjetillll/perl/ch-2.pl | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/challenge-123/kjetillll/perl/ch-2.pl b/challenge-123/kjetillll/perl/ch-2.pl index 72a1cc3c48..c3b8be3be3 100644 --- a/challenge-123/kjetillll/perl/ch-2.pl +++ b/challenge-123/kjetillll/perl/ch-2.pl @@ -10,8 +10,8 @@ sub is_square { die if @_ != 4 or grep@$_!=2,@_; my %dsf; #dsf=distance squared found - for my $p1 (0..2){ # for the three first points - for my $p2 ($p1..3){ # loop through the rest of the points + for my $p1 ( 0 .. 2 ){ # for the three first points + for my $p2 ( $p1+1 .. 3 ){ # loop through the rest of the points my($p1x,$p1y,$p2x,$p2y)=(@{$_[$p1]},@{$_[$p2]}); $dsf{ ($p1x-$p2x)**2 + ($p1y-$p2y)**2 }++; #register distance squared }} |
