projects
/
advent-of-code-22.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b8fa5f9
)
Point-free disjoint
author
Neil Smith
<NeilNjae@users.noreply.github.com>
Sun, 4 Dec 2022 10:42:20 +0000
(10:42 +0000)
committer
Neil Smith
<NeilNjae@users.noreply.github.com>
Sun, 4 Dec 2022 10:42:20 +0000
(10:42 +0000)
advent04/Main.hs
patch
|
blob
|
history
diff --git
a/advent04/Main.hs
b/advent04/Main.hs
index 456b157c6af47a8eda8d32d7b6bbace22c1b2540..a295abfe1bfb30d8249c1fd39c499a2e3ef7ab74 100644
(file)
--- a/
advent04/Main.hs
+++ b/
advent04/Main.hs
@@
-40,13
+40,14
@@
hasContainment (assignment1, assignment2) =
disjoint (assignment1, assignment2) =
(assignment1 `before` assignment2) || (assignment2 `before` assignment1)
disjoint (assignment1, assignment2) =
(assignment1 `before` assignment2) || (assignment2 `before` assignment1)
-overlaps
pair = not $ disjoint pair
+overlaps
= not . disjoint
contains, before :: Assignment -> Assignment -> Bool
contains (Assignment lower1 upper1) (Assignment lower2 upper2) =
(lower1 <= lower2) && (upper1 >= upper2)
contains, before :: Assignment -> Assignment -> Bool
contains (Assignment lower1 upper1) (Assignment lower2 upper2) =
(lower1 <= lower2) && (upper1 >= upper2)
-before (Assignment _lower1 upper1) (Assignment lower2 _upper2) = (upper1 < lower2)
+before (Assignment _lower1 upper1) (Assignment lower2 _upper2) =
+ (upper1 < lower2)
-- Parse the input file
-- Parse the input file