Skip to content

Commit 41a58d8

Browse files
committed
2016, Day 18
1 parent 724b42b commit 41a58d8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

2016/18/haskell/18.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
iter xs = aux ('.' : xs ++ ".")
2+
where
3+
aux (a : b : c : xs) = (if a == c then '.' else '^') : aux (b : c : xs)
4+
aux _ = []
5+
6+
main = do
7+
let input = "^.^^^.^..^....^^....^^^^.^^.^...^^.^.^^.^^.^^..^.^...^.^..^.^^.^..^.....^^^.^.^^^..^^...^^^...^...^."
8+
let rows = iterate iter input
9+
print $ length $ filter (== '.') $ concat $ take 40 rows
10+
print $ length $ filter (== '.') $ concat $ take 400000 rows

0 commit comments

Comments
 (0)