aboutsummaryrefslogtreecommitdiff
path: root/challenge-059/simon-proctor/raku/ch-2.raku
blob: ad595b2d8cee0fbfa51c0f5bd5fafbee58654922 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env raku

use v6;

sub bit-diff( UInt $a, UInt $b ) {
    [+] ($a +^ $b).base(2).comb;
}

#| Give the sum of the differences in bits between all the combinations of inputs
sub MAIN (
    *@vals where { $_.all ~~ UInt } #= Integer values to combine
){
    say [+] @vals.combinations(2).map( { bit-diff( |@_ ) } );
}