day3: Significantly improve answer
This commit is contained in:
parent
1b7f5d83a0
commit
04a9814f1c
|
@ -46,10 +46,7 @@ listToBit list = foldr (\b acc -> (acc + toBit b)) 0 (enumerate (reverse list))
|
|||
else 0
|
||||
|
||||
filterForLife :: ([Int] -> Int) -> [[Int]] -> [[Int]]
|
||||
filterForLife targetFilter list = foldl (filterNext) list [0..length(head list)-1]
|
||||
where
|
||||
filterNext :: [[Int]] -> Int-> [[Int]]
|
||||
filterNext acc i = acc `intersect` filterIndex targetFilter acc i
|
||||
filterForLife targetFilter list = foldl (filterIndex targetFilter) list [0..length(head list)-1]
|
||||
|
||||
filterIndex :: ([Int] -> Int) -> [[Int]] -> Int -> [[Int]]
|
||||
filterIndex targetFilter list index = filter ((==filterTarget) . (!! index)) list
|
||||
|
|
Loading…
Reference in a new issue