repositories
/
aoc20.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a9b3526
)
make work for non rectangular fields as well
author
Mart Lubbers
<mart@martlubbers.net>
Fri, 11 Dec 2020 09:06:24 +0000
(10:06 +0100)
committer
Mart Lubbers
<mart@martlubbers.net>
Fri, 11 Dec 2020 09:06:24 +0000
(10:06 +0100)
11/one.icl
patch
|
blob
|
history
diff --git
a/11/one.icl
b/11/one.icl
index
f96a677
..
7db34d4
100644
(file)
--- 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
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
= 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
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]
= ls.[y,x]