diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-10-21 16:39:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-21 16:39:41 +0100 |
| commit | d40c1cc5b822fab79746640fa05b7a338e90bffc (patch) | |
| tree | 48ad0aa2b4859e6ea33e9390eadce33c3952951e | |
| parent | 4ffcc2b1f2a4affbe32de7d8662c4955184fd8b7 (diff) | |
| parent | 368712a38adde5d366c0d8c7496a96aeee80ed24 (diff) | |
| download | perlweeklychallenge-club-d40c1cc5b822fab79746640fa05b7a338e90bffc.tar.gz perlweeklychallenge-club-d40c1cc5b822fab79746640fa05b7a338e90bffc.tar.bz2 perlweeklychallenge-club-d40c1cc5b822fab79746640fa05b7a338e90bffc.zip | |
Merge pull request #821 from k-mx/master
improved challenge-031.1 by Maxim Kolodyazhny
| -rw-r--r-- | challenge-031/maxim-kolodyazhny/perl5/ch-1.pl | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/challenge-031/maxim-kolodyazhny/perl5/ch-1.pl b/challenge-031/maxim-kolodyazhny/perl5/ch-1.pl index 015c03f4b5..68e4bea178 100644 --- a/challenge-031/maxim-kolodyazhny/perl5/ch-1.pl +++ b/challenge-031/maxim-kolodyazhny/perl5/ch-1.pl @@ -3,8 +3,12 @@ use strict; use warnings; -sub div { +use constant ANSWER2EVERYTHING => 42; + +sub harmless_division { my ($x, $y ) = @_; - 42^$y^42 ? $x / $y : undef; + return if $y == int $y && ( ANSWER2EVERYTHING ^ $y ) == ANSWER2EVERYTHING; + + $x / $y; } |
