diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-02-13 00:15:01 +0000 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-02-13 00:15:01 +0000 |
| commit | ade5d9a9e4585f1ec707a898824558affc9a8797 (patch) | |
| tree | 1f8aca6e29e3676790d32e7f6693edcd06e23f32 /challenge-097 | |
| parent | a92b0cbe099dd187ea794e76c89061040f260795 (diff) | |
| download | perlweeklychallenge-club-ade5d9a9e4585f1ec707a898824558affc9a8797.tar.gz perlweeklychallenge-club-ade5d9a9e4585f1ec707a898824558affc9a8797.tar.bz2 perlweeklychallenge-club-ade5d9a9e4585f1ec707a898824558affc9a8797.zip | |
some better golfing - over 30% shorter solution for ch-2.pl
Diffstat (limited to 'challenge-097')
| -rw-r--r-- | challenge-097/james-smith/perl/ch-2.pl | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/challenge-097/james-smith/perl/ch-2.pl b/challenge-097/james-smith/perl/ch-2.pl index 94aa8088cc..d625ab9d87 100644 --- a/challenge-097/james-smith/perl/ch-2.pl +++ b/challenge-097/james-smith/perl/ch-2.pl @@ -132,11 +132,11 @@ sub min_flips { ]->[-1] } -sub mf_1{[local$\=local$/=length$_[0],$\/=$_[1],map{$/=$_<$/?$_:$/}map{($_[0]^$_)=~y/\1/\1/}map{$_ x$\}map{substr$_[0],$_,$_[1]}map{$_*$_[1]}0..$\-1]->[-1];} -## Now as a one liner [all 157 characters] +sub mf_1{[local$\=local$/=length$_[0],$\/=$_[1],map{$/=$_<$/?$_:$/}map{($_[0]^$_)=~y/\1/\1/}map{$_ x$\}map{substr$_[0],$_,$_[1]}map{$_*$_[1]}0..$\-1]->[-1]} +## Now as a one liner [all 156 characters] - 146 inside the curly braces.. sub mf_2{[local$\=local$/=length$_[0],$\/=$_[1],map{$/=$_<$/?$_:$/}map{($_[0]^$_ -)=~y/\1/\1/}map{$_ x$\}map{substr$_[0],$_,$_[1]}map{$_*$_[1]}0..$\-1]->[-1];} +)=~y/\1/\1/}map{$_ x$\}map{substr$_[0],$_,$_[1]}map{$_*$_[1]}0..$\-1]->[-1]} ## With the white space back in.. |
