Skip to content

Commit eb1dca3

Browse files
refactor(day4): simplify part 2
1 parent a81f09f commit eb1dca3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

solutions/Days/Day04.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ parseInput = either (error . errorBundlePretty) id . parse pInput ""
2323
part1 :: [(Range, Range)] -> Int
2424
part1 = length . filter f
2525
where
26-
f ((a, b), (c, d)) = (a >= c && b <= d) || (c >= a && d <= b)
26+
f ((s1, e1), (s2, e2)) = (s1 >= s2 && e1 <= e2) || (s2 >= s1 && e2 <= e1)
2727

2828
part2 :: [(Range, Range)] -> Int
2929
part2 = length . filter f
3030
where
31-
f ((a, b), (c, d)) = (c >= a && c <= b) || (a >= c && a <= d)
31+
f ((s1, e1), (s2, e2)) = s1 <= e2 && s2 <= e1
3232

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy