projects
/
advent-of-code-23.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Done day 22
[advent-of-code-23.git]
/
advent05
/
Main.hs
diff --git
a/advent05/Main.hs
b/advent05/Main.hs
index 17e38bd384c0d4fcff8e75dc98f150e46939f035..d8bb80651619e20b6408db47ece5cfb9e999f897 100644
(file)
--- a/
advent05/Main.hs
+++ b/
advent05/Main.hs
@@
-39,7
+39,7
@@
lowestLocation almanac seeds = l
(Iv l _) = head locations
followRequirements :: Almanac -> Requirement -> Requirement
(Iv l _) = head locations
followRequirements :: Almanac -> Requirement -> Requirement
-followRequirements _ req@(Requirement "location"
vals
) = req
+followRequirements _ req@(Requirement "location"
_
) = req
followRequirements almanac (Requirement name vals) =
followRequirements almanac newReq
where aMap = almanac ! name
followRequirements almanac (Requirement name vals) =
followRequirements almanac newReq
where aMap = almanac ! name
@@
-61,9
+61,9
@@
useRule (Rule (Iv rl rh) d) (Iv xl xh) = (newResults, newVals, newRules)
useRules :: [Rule] -> [Interval] -> [Interval]
useRules [] vals = vals
useRules _ [] = []
useRules :: [Rule] -> [Interval] -> [Interval]
useRules [] vals = vals
useRules _ [] = []
-useRules (r@(Rule
(Iv rl rh) _):rs) (v@(Iv xl xh)
:vs)
- | r
h < xl
= useRules rs (v:vs)
- |
xh < rl
= v : useRules (r:rs) vs
+useRules (r@(Rule
rv _):rs) (v
:vs)
+ | r
v `allBelow` v
= useRules rs (v:vs)
+ |
v `allBelow` rv
= v : useRules (r:rs) vs
| otherwise = newResults ++ (useRules (newRules ++ rs) (newVals ++ vs))
where (newResults, newVals, newRules) = useRule r v
| otherwise = newResults ++ (useRules (newRules ++ rs) (newVals ++ vs))
where (newResults, newVals, newRules) = useRule r v
@@
-87,7
+87,7
@@
expandRanges seeds = fmap expandRange ranges
tidyIntervals :: [Interval] -> [Interval]
tidyIntervals :: [Interval] -> [Interval]
-tidyIntervals
ivs0 = tidyIntervalsS $ sort ivs0
+tidyIntervals
= tidyIntervalsS . sort
tidyIntervalsS :: [Interval] -> [Interval]
tidyIntervalsS [] = []
tidyIntervalsS :: [Interval] -> [Interval]
tidyIntervalsS [] = []