projects
/
advent-of-code-22.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Renamed norm
[advent-of-code-22.git]
/
advent09
/
Main.hs
diff --git
a/advent09/Main.hs
b/advent09/Main.hs
index 0ad2bb5e2eecfe98e7e8fc3c59d28dd8cadc8a8d..4273e24d61deb1003d8a2dc88078432ec5d93d4e 100644
(file)
--- a/
advent09/Main.hs
+++ b/
advent09/Main.hs
@@
-48,12
+48,12
@@
expandPath = concatMap expandStep
expandStep (D n) = replicate n (V2 0 -1)
expandStep (R n) = replicate n (V2 1 0)
expandStep (D n) = replicate n (V2 0 -1)
expandStep (R n) = replicate n (V2 1 0)
-
manhattan
:: Position -> Position -> Int
-
manhattan
p1 p2 = max dx dy
+
lInfNorm
:: Position -> Position -> Int
+
lInfNorm
p1 p2 = max dx dy
where V2 dx dy = abs $ p1 ^-^ p2
touching :: Position -> Position -> Bool
where V2 dx dy = abs $ p1 ^-^ p2
touching :: Position -> Position -> Bool
-touching p1 p2 = (
manhattan
p1 p2) <= 1
+touching p1 p2 = (
lInfNorm
p1 p2) <= 1
towards :: Position -> Position -> Position
towards p1 p2 = signum $ p2 ^-^ p1
towards :: Position -> Position -> Position
towards p1 p2 = signum $ p2 ^-^ p1