From 66bb407b8e8517bd246c334bb66ad70e202a6909 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Fri, 11 Dec 2020 10:06:24 +0100 Subject: [PATCH] make work for non rectangular fields as well --- 11/one.icl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/11/one.icl b/11/one.icl index f96a677..7db34d4 100644 --- a/11/one.icl +++ b/11/one.icl @@ -35,7 +35,7 @@ numOccupied ls = length [()\\r<-:ls, c<-:r | c == '#'] cell :: (Int Int Int Int {#String} -> Bool) (Int -> Bool) (Int -> Bool) {#String} -> {#String} cell lookfun live die ls - # ls` = {{step x y\\x<-[0..size ls.[0] - 1]}\\y<-[0..size ls - 1]} + # ls` = {{step x y\\x<-[0..size ls.[y] - 1]}\\y<-[0..size ls - 1]} = if (and [l==r\\l<-:ls` & r<-:ls]) ls (cell lookfun live die ls`) where step x y = case ls.[y,x] of @@ -47,5 +47,5 @@ where seat :: Int Int {#String} -> Char seat x y ls - | x < 0 || x >= size ls.[0] || y < 0 || y >= size ls = '-' + | y < 0 || y >= size ls || x < 0 || x >= size ls.[y] = '-' = ls.[y,x] -- 2.20.1