Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Population-count/Raku/population-count-1.raku
Normal file
5
Task/Population-count/Raku/population-count-1.raku
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
sub population-count(Int $n where * >= 0) { [+] $n.base(2).comb }
|
||||
|
||||
say map &population-count, 3 «**« ^30;
|
||||
say "Evil: ", (grep { population-count($_) %% 2 }, 0 .. *)[^30];
|
||||
say "Odious: ", (grep { population-count($_) % 2 }, 0 .. *)[^30];
|
||||
6
Task/Population-count/Raku/population-count-2.raku
Normal file
6
Task/Population-count/Raku/population-count-2.raku
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
sub population-count(Int $n is copy where * >= 0) {
|
||||
loop (my $c = 0; $n; $n +>= 1) {
|
||||
$c += $n +& 1;
|
||||
}
|
||||
$c;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue