Skip to content

Commit

Permalink
Merge pull request manwar#1665 from Scimon/master
Browse files Browse the repository at this point in the history
Bitwise XOR of course.
  • Loading branch information
manwar authored May 4, 2020
2 parents 49a15dc + 926adde commit bd1cc9e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions challenge-059/simon-proctor/raku/ch-2.raku
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bd1cc9e

Please sign in to comment.