diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-05-04 10:16:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-04 10:16:37 +0100 |
| commit | bd1cc9eb1a4c1e1bdd6951a82a899e2be6c64424 (patch) | |
| tree | 11cd62e0f29377c7e91acad67d3b6c3dcf03cb6b | |
| parent | 49a15dc1ea62a46f101c3b508542e245bba04890 (diff) | |
| parent | 926addea943c4d8b64fa8c5476a931d55379593c (diff) | |
| download | perlweeklychallenge-club-bd1cc9eb1a4c1e1bdd6951a82a899e2be6c64424.tar.gz perlweeklychallenge-club-bd1cc9eb1a4c1e1bdd6951a82a899e2be6c64424.tar.bz2 perlweeklychallenge-club-bd1cc9eb1a4c1e1bdd6951a82a899e2be6c64424.zip | |
Merge pull request #1665 from Scimon/master
Bitwise XOR of course.
| -rw-r--r-- | challenge-059/simon-proctor/raku/ch-2.raku | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/challenge-059/simon-proctor/raku/ch-2.raku b/challenge-059/simon-proctor/raku/ch-2.raku index 224906b720..ad595b2d8c 100644 --- a/challenge-059/simon-proctor/raku/ch-2.raku +++ b/challenge-059/simon-proctor/raku/ch-2.raku @@ -2,12 +2,10 @@ use v6; -multi sub bit-diff( UInt $a, UInt $b where $a >= $b ) { - [+] ($a.base(2).comb.reverse Z (|$b.base(2).comb.reverse, |(lazy gather { take 0 }) ) ).map( { abs( $^a[0] - $^a[1] ) } ); +sub bit-diff( UInt $a, UInt $b ) { + [+] ($a +^ $b).base(2).comb; } -multi sub bit-diff( UInt $a, UInt $b ) { bit-diff( $b, $a ) } - #| Give the sum of the differences in bits between all the combinations of inputs sub MAIN ( *@vals where { $_.all ~~ UInt } #= Integer values to combine |
