projects
/
advent-of-code-24.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0f3d173
)
Tidying
author
Neil Smith
<NeilNjae@users.noreply.github.com>
Mon, 2 Dec 2024 19:59:19 +0000
(19:59 +0000)
committer
Neil Smith
<NeilNjae@users.noreply.github.com>
Mon, 2 Dec 2024 19:59:19 +0000
(19:59 +0000)
advent02/Main.hs
patch
|
blob
|
history
diff --git
a/advent02/Main.hs
b/advent02/Main.hs
index cb75ccb1300567ebe57196d7bd777e8cfedacd3a..bd4df3aebc3e93c548a1894c3978db26b98345d2 100644
(file)
--- a/
advent02/Main.hs
+++ b/
advent02/Main.hs
@@
-20,10
+20,10
@@
isSafe, allSameSign, bigEnough, smallEnough, safeWhenDamped :: [Int] -> Bool
isSafe xs = allSameSign diffs && bigEnough diffs && smallEnough diffs
where diffs = zipWith (-) xs (tail xs)
-allSameSign xs
- | all (>0) xs = True
- | all (<0) xs = True
- | otherwise = False
+allSameSign xs
= (all (>0) xs) || (all (<0) xs)
+
--
| all (>0) xs = True
+
--
| all (<0) xs = True
+
--
| otherwise = False
bigEnough = all ((>= 1) . abs)
smallEnough = all ((<= 3) . abs)