diff options
| author | James Smith <js5@sanger.ac.uk> | 2021-04-10 11:10:33 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-10 11:10:33 +0100 |
| commit | d4dfd166ab137d9e8f007cd5c2c422cdee06abd3 (patch) | |
| tree | 18e79d6411eee8904efdedd17792d7258b764f75 | |
| parent | 6262a8a0e3889940110042c265c2615b68432d85 (diff) | |
| download | perlweeklychallenge-club-d4dfd166ab137d9e8f007cd5c2c422cdee06abd3.tar.gz perlweeklychallenge-club-d4dfd166ab137d9e8f007cd5c2c422cdee06abd3.tar.bz2 perlweeklychallenge-club-d4dfd166ab137d9e8f007cd5c2c422cdee06abd3.zip | |
Update ch-1.pl
| -rw-r--r-- | challenge-107/james-smith/perl/ch-1.pl | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/challenge-107/james-smith/perl/ch-1.pl b/challenge-107/james-smith/perl/ch-1.pl index fff417572c..a791fd9a95 100644 --- a/challenge-107/james-smith/perl/ch-1.pl +++ b/challenge-107/james-smith/perl/ch-1.pl @@ -1,3 +1,36 @@ +Skip to content +Search or jump to… + +Pull requests +Issues +Marketplace +Explore + +@drbaggy +drbaggy +/ +perlweeklychallenge-club +forked from manwar/perlweeklychallenge-club +0 +0 +204 +Code +Pull requests +Actions +Projects +Wiki +Security +Insights +Settings +perlweeklychallenge-club/challenge-107/james-smith/perl/ch-1.pl +@drbaggy +drbaggy Documentation, some more golfing on ch-2 and an example of the differ… +… +Latest commit 2b79dbf 4 days ago + History + 1 contributor +129 lines (113 sloc) 4.16 KB + #!/usr/local/bin/perl use strict; @@ -116,6 +149,7 @@ perl -E '($c-join"",map{0+(@Q=$c=~/($_)/g)}0..-1+length$c)||++$n&&say$c while++$ ## ## * To gain another character as the equality is numeric we can ## rewrite if($a==$b) { f() } as ($a-$b)||f(). +## ## $a-$b is non-zero (true) if $a!=$b so we can rewrite: ## ## if( $a == $b ) { f() } @@ -127,3 +161,10 @@ perl -E '($c-join"",map{0+(@Q=$c=~/($_)/g)}0..-1+length$c)||++$n&&say$c while++$ ## which we know we mentioned we could rewrite as: ## ## ($a-$b) || f() +## +## The brackets are important o/w this evaluates to: +## +## $a-($b||f()) +## +## which isn't what we want... +## |
