diff options
| author | Fung Cheok Yin <61836418+E7-87-83@users.noreply.github.com> | 2020-08-23 07:37:03 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-23 07:37:03 +0800 |
| commit | 421c43c0346eeeaf994cba0481e66773b432a098 (patch) | |
| tree | a1ecda1882d211b4e44afc7cf41292f1219a65cc | |
| parent | 0dc9a9f30184ec760f442d60aec1fdf9b92dbbaf (diff) | |
| download | perlweeklychallenge-club-421c43c0346eeeaf994cba0481e66773b432a098.tar.gz perlweeklychallenge-club-421c43c0346eeeaf994cba0481e66773b432a098.tar.bz2 perlweeklychallenge-club-421c43c0346eeeaf994cba0481e66773b432a098.zip | |
Update ch-1.pl
condense
| -rw-r--r-- | challenge-074/cheok-yin-fung/perl/ch-1.pl | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/challenge-074/cheok-yin-fung/perl/ch-1.pl b/challenge-074/cheok-yin-fung/perl/ch-1.pl index feb190e26c..0b67899143 100644 --- a/challenge-074/cheok-yin-fung/perl/ch-1.pl +++ b/challenge-074/cheok-yin-fung/perl/ch-1.pl @@ -16,9 +16,7 @@ sub verify { my $m = $_[1]; my $c = 0; for (@array) { - if ($m==$_) { - $c++; - } + $c++ if $m==$_; } return ($c > (scalar @array)/2.0 ? 1 : undef); } @@ -32,11 +30,8 @@ sub bm_majority_vote_alg { $m = $_; $i++ } - elsif ($m == $_) { - $i++; - } else { - $i--; + $m == $_ ? $i++ : $i--; } } |
