From: Neil Smith Date: Fri, 16 Dec 2016 08:55:19 +0000 (+0000) Subject: Using lazy lists works eventually X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=def5eb181275889c4f50ea8411dff81bd565efb2;p=advent-of-code-16.git Using lazy lists works eventually --- diff --git a/advent15l.hs b/advent15l.hs index e3c97fb..f04ab9c 100644 --- a/advent15l.hs +++ b/advent15l.hs @@ -12,8 +12,8 @@ part1 :: [[Int]] -> IO () part1 disks = print $ head $ filter (canFall disks) [0..] part2 :: [[Int]] -> IO () -part2 disks = print $ head $ filter (canFall disks2) [0..5000000] - where disks2 = id $! map (take 5000000) $ disks ++ [drop 7 $ drop 0 $ cycle [0..(11-1)]] +part2 disks = print $ head $ filter (canFall disks2) [0..] + where disks2 = disks ++ [drop 7 $ drop 0 $ cycle [0..(11-1)]] canFall :: [[Int]] -> Int -> Bool canFall ds i = all (\d -> (d!!i) == 0) ds