Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Population-count/Miranda/population-count.miranda
Normal file
15
Task/Population-count/Miranda/population-count.miranda
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
main :: [sys_message]
|
||||
main = [Stdout (lay (map (show . take 30) [powers_of_3, evil, odious]))]
|
||||
|
||||
powers_of_3 :: [num]
|
||||
powers_of_3 = map (popcount . (3^)) [0..]
|
||||
|
||||
evil :: [num]
|
||||
evil = filter f [0..] where f n = popcount n mod 2 = 0
|
||||
|
||||
odious :: [num]
|
||||
odious = filter f [0..] where f n = popcount n mod 2 = 1
|
||||
|
||||
popcount :: num -> num
|
||||
popcount 0 = 0
|
||||
popcount n = n mod 2 + popcount (n div 2)
|
||||
Loading…
Add table
Add a link
Reference in a new issue