diff options
| author | James Smith <baggy@baggy.me.uk> | 2021-10-19 17:17:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-19 17:17:19 +0100 |
| commit | f0c53411527854718c62824b270aac3d0d2f041b (patch) | |
| tree | dc40fb92749908e8f0ce6ed411f695b1be259e3d | |
| parent | bb11efe8163a07c07c4c53edd0d82c6096bfeb90 (diff) | |
| download | perlweeklychallenge-club-f0c53411527854718c62824b270aac3d0d2f041b.tar.gz perlweeklychallenge-club-f0c53411527854718c62824b270aac3d0d2f041b.tar.bz2 perlweeklychallenge-club-f0c53411527854718c62824b270aac3d0d2f041b.zip | |
Update README.md
| -rw-r--r-- | challenge-135/james-smith/README.md | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/challenge-135/james-smith/README.md b/challenge-135/james-smith/README.md index dbb2c8cdca..79fea8463a 100644 --- a/challenge-135/james-smith/README.md +++ b/challenge-135/james-smith/README.md @@ -83,13 +83,13 @@ sub is_sedol { Again we can compact the code - by removing spaces and a couple of rewrites: * replace `unless $x=~//` with `if $x!~//`; - * replace `$x?0:1` with `1^!$x`. + * flip `@w` and use `pop`. ```perl sub is_sedol_compact { return 0 if$_[0]!~/^[0-9B-HJ-NP-TW-Z]{6}\d$/; - my($t,@w)=qw(0 1 3 1 7 3 9 1); - $t+=(/\d/?$_:-55+ord$_)*shift@w for split//,$_[0]; - 1^!$t%10; + my($t,@w)=qw(0 1 9 3 7 1 3 1); + $t+=(/\d/?$_:-55+ord$_)*pop@w for split//,$_[0]; + $t%10?0:1; } ``` |
