Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
9
Task/Population-count/Crystal/population-count.crystal
Normal file
9
Task/Population-count/Crystal/population-count.crystal
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
struct Int
|
||||
def evil?
|
||||
self >= 0 && popcount.even?
|
||||
end
|
||||
end
|
||||
|
||||
puts "Powers of 3:", (0...30).map{|n| (3u64 ** n).popcount}.join(' ') # can also use &** (to prevent arithmetic overflow)
|
||||
puts "Evil:" , 0.step.select(&.evil?).first(30).join(' ')
|
||||
puts "Odious:", 0.step.reject(&.evil?).first(30).join(' ')
|
||||
Loading…
Add table
Add a link
Reference in a new issue