aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-059/simon-proctor/raku/ch-2.raku6
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