diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-03-02 01:23:45 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-02 01:23:45 +0000 |
| commit | 1f49683f9eb35276d378852860a3ff1a7f79ba67 (patch) | |
| tree | 1db28a2013861a275b59a13c3460ad044c70eb41 /challenge-101 | |
| parent | cf5f6b6313cc0fb8c60b2faa5cae3bfed7ded9d3 (diff) | |
| parent | 0fcae0e3bbf055a15c15fb933812ee9e62238c66 (diff) | |
| download | perlweeklychallenge-club-1f49683f9eb35276d378852860a3ff1a7f79ba67.tar.gz perlweeklychallenge-club-1f49683f9eb35276d378852860a3ff1a7f79ba67.tar.bz2 perlweeklychallenge-club-1f49683f9eb35276d378852860a3ff1a7f79ba67.zip | |
Merge pull request #3641 from PerlBoy1967/branch-for-challenge-101
Mitigate 'divide by zero' (one of the corners of the triagle is (0,0))
Diffstat (limited to 'challenge-101')
| -rwxr-xr-x | challenge-101/perlboy1967/perl/ch-2.pl | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/challenge-101/perlboy1967/perl/ch-2.pl b/challenge-101/perlboy1967/perl/ch-2.pl index 5af3cf8aa7..cea46714dc 100755 --- a/challenge-101/perlboy1967/perl/ch-2.pl +++ b/challenge-101/perlboy1967/perl/ch-2.pl @@ -24,6 +24,7 @@ my %triangles = ( 'Example 1' => [0,1,1,0,2,2], 'Example 2' => [1,1,-1,1,0,-3], 'Example 3' => [0,1,2,0,-6,0], + 'Example 4' => [-1,0,0,0,0,1], ); foreach my $c (sort keys %triangles) { @@ -51,6 +52,10 @@ sub calcZAngle($$$$) { sub originInsideTriangle (@) { my ($x1,$y1,$x2,$y2,$x3,$y3) = @_; + return 1 if ($x1 == 0 and $y1 == 0); + return 1 if ($x2 == 0 and $y2 == 0); + return 1 if ($x3 == 0 and $y3 == 0); + # calculate angles: # AzB, BzC and AzC my %angle; |
