From 28763275f4741e2244372ddfaafb2d750a1cfcfb Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Fri, 11 Dec 2020 09:29:53 +0100 Subject: [PATCH] 11.1 --- 11/input | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 11/input2 | 10 ++++++ 11/one.icl | 42 +++++++++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 11/input create mode 100644 11/input2 create mode 100644 11/one.icl diff --git a/11/input b/11/input new file mode 100644 index 0000000..7b26308 --- /dev/null +++ b/11/input @@ -0,0 +1,98 @@ +LLLLL.LLLL.LLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLL.LLLLLLLLL.LLLLLLL.LLLLLLLLLLLL.LL.LLLLLLLLL.LLL +LLLLLLLL.L.LLLLLLL.LLLLLLLLLLLL.LLLLLLLLLLLLL.LLLLLLLLL.LLL.LLL.LLLLL.LLLL.L..LLLLLL.LLLLLLLL +LLLLLLLLLLLLLLLLLLLLLLLLLLL.LL.LLLLLLLLLLLLLL..LLLLLLLL.L.LLLLLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLL +LLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLL.LLLLL.LL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLL.LLL.LLLLL.LL +LLLLLLLLLL.LLLLL.LLL.LLLLLL.LLLLLLL..LLLLLLLL.LLLLLLLLL.LLLLLLL.LLLLL.LLLLLL..LLLLLL.LLLLLLLL +LLLLLLLLLL..LLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLL.LLLLLLLLL.LL.LLLL.LLLLLLLLLLLL.LLLLLLL.LLLLLL.L +L.LL.L...LL......LLL........LL...L.L.L...L...L....L........LL......L.............LL..LL.L...L +LLLLLLLLL..LL.LLLL.L.LL.LLL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLL +LLLLLL.LLL.LLLLLLL.LLLLLLLL.LLLLLLL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LLLLLLLLLLL.LLLLLLLLLLLL.LLL +LLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLL.LLLLLLLL +LL..L....L...L.L........L.L....L..L..L...L..L..L........L...LLL..L.LL..L........LL..........L +LLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLLL.LLLLLLL.L.LLLLLLLLL.LLLL.LL.LLLLL.LLLLLLLLLLL.LL.LLLLLLL. +LLLLLLLLLL.LLLLLLL.LLLLLL.L.LL.L.LL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLL +LLLLLLLLLL.LLLLLLL.LLLLLL.LLL.LLL.L.LLLLLLLLL.LLLLLL.LL.LLLLLL..LLLLL.LLLLLL.LLL.LLLLLLLLLLLL +LLLLLLL.LL.LLLL.LL.LLLLLLLL.LLLLLLL.LLLLLLLLL.LLLLLLLLL.LLLLLLL.LLLLL.LLLLLLLLLLLLLL.LLLLLLLL +.LL.LLLLLLL.LLLLLLLLLLL.LLL.LLLLLLLLLLLLLLLLL.LLLLLLLLL.LLLL.LL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLL +LL.LLLLLLLLLLLLLLL.LLLLLLL..LLLLLLLLLLLLLLLLL.LLLLLLLLL..LLLL.L.LLLLLLLLLLLLLL.LLLLL.LLLLLLLL +.....L.....LLLL......LL.L...LL...L..L........L...L..LL..LL.LL.LL..LL...L.......L..LLL..L...LL +LLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLLL.LLLLLLLLL.LLLLLLLLL.LLLLLLL.L.LLL.LLLLLL.LLLLLL..LLLLLLLL +.LLLLLLL.L.LL.LL.L.LLLLL.L..LLLLLLLLLLLLLLLLLLLLLLLL.LL.LLLLLLLLLLLLL.LLLLLL.LLLL.LL.LLLLLLLL +LLLLLLLLLL..LLLLLL.LLLLLLLL.LLLLLLL..LLLLLLLL.LLLLLLLLL.LLLLLLL.LLLLLLLLLLLLL.LL.LLL.LL.LLLL. +LLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLLL.LLL.LL.LL.LLLLL.LLL.LLLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLLLLLL +LLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLL.LLLL.LL.LLL.L.LLL.LLLLLLL.LLL.L.LLLL.LLLLLLLLL.LLLLLLLL +..L...LLL..LL...L.L.LLLL..L.L...L..LLL...L...LLL.....L.....LL.L....L....L.L..L.L.L....L..L..L +LLLLLLLLLLLLLLLLLL.LLL.LLLL.LLLLLLL.LLLLLLLLL.LL.LLLL.LLLLL.L.L.LLLLL.LLLLLL.LLL.LLL.LLLLLL.L +LLLLLLLLLL.LLLLLLLLLLLLLLLL.LL.LL.L.LLLLLLLLL..LL.LLLLL.LLLLLLLLLLL.L.L.L.LL.LLLLLLL.LLLLLLLL +LLLLLLLLLL.LLLLLLL.LLLLLL.LLLLLL.LL.LLLLLLLLLLLLLLLLLLL.LL.LL.L.LLLLL.LLLLLLLLL.LLLL.LLLLLLLL +LLLLLLLLLL..LLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLL.LLLLLLL.L.LLLLLLL.LLLLLLLLLLLL.LLLLLLL..LLLLLLL +LL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLL.LLLLLL.LLL..LL.LLLLLLLL diff --git a/11/input2 b/11/input2 new file mode 100644 index 0000000..1beaede --- /dev/null +++ b/11/input2 @@ -0,0 +1,10 @@ +L.LL.LL.LL +LLLLLLL.LL +L.L.L..L.. +LLLL.LL.LL +L.LL.LL.LL +L.LLLLL.LL +..L.L..... +LLLLLLLLLL +L.LLLLLL.L +L.LLLLL.LL diff --git a/11/one.icl b/11/one.icl new file mode 100644 index 0000000..2745c1e --- /dev/null +++ b/11/one.icl @@ -0,0 +1,42 @@ +module one + +import StdEnv +import Data.Func + +import Text + +read :: *File -> [String] +read f + # (l, f) = freadline f + | l.[size l - 1] <> '\n' = [] + = [l % (0, size l - 2):read f] + +Start w + # (io, w) = stdio w + # ls = read io + # ls = {l\\l<-ls} + = one ls + +instance == {#String} where + (==) l r = and [l==r\\l<-:l & r<-:r] + +one :: {#String} -> Int +one ls = length [()\\r<-:cell ls, c<-:r | c == '#'] + +cell :: !{#String} -> {#String} +cell ls = let ls` = step ls in if (ls` == ls) ls (cell ls`) + +step :: !{#String} -> {#String} +step ls = {{step` x y\\x<-[0..size ls.[0] - 1]}\\y<-[0..size ls - 1]} +where + step` :: Int Int -> Char + step` x y = case ls.[y,x] of + '.' = '.' + 'L' = if (occupied == 0) '#' 'L' + '#' = if (occupied >= 4) 'L' '#' + where + occupied = length [()\\dx<-[-1..1], dy<-[-1..1] | not (dx == 0 && dy == 0) && not (empty (x+dx) (y+dy))] + empty :: Int Int -> Bool + empty x y + | x < 0 || x >= size ls.[0] || y < 0 || y >= size ls = True + = ls.[y,x] <> '#' -- 2.20.1