Skip to content

Commit

Permalink
refactor(2024.02-haskell): tidy a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
yurrriq committed Dec 21, 2024
1 parent 2839b28 commit 5f6c3b9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.5.1.1
2024.5.1.2
5 changes: 2 additions & 3 deletions src/AdventOfCode/Year2024/Day02.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ example =
]

isSafe :: [Integer] -> Bool
isSafe xs = all (== head signs) (tail signs) && all (inRange (1, 3) . abs) diffs
isSafe xs = any (all (inRange (1, 3))) [diffs, negate <$> diffs]
where
diffs = zipWith (-) (tail xs) xs
signs = map signum diffs
diffs = zipWith subtract xs (tail xs)

0 comments on commit 5f6c3b9

Please sign in to comment.