Clean bench
This commit is contained in:
@@ -11,14 +11,14 @@ type Intermediate = [(Interval, Interval)]
|
||||
|
||||
makeInterval :: (Ord a) => a -> a -> (a, a)
|
||||
makeInterval a b
|
||||
| a > b = (b, a)
|
||||
| otherwise = (a, b)
|
||||
| a > b = (b, a)
|
||||
| otherwise = (a, b)
|
||||
|
||||
parser :: Parser Intermediate
|
||||
parser = someLines ((,) <$> interval <* char ',' <*> interval)
|
||||
where
|
||||
interval :: Parser Interval
|
||||
interval = makeInterval <$> number <* char '-' <*> number
|
||||
where
|
||||
interval :: Parser Interval
|
||||
interval = makeInterval <$> number <* char '-' <*> number
|
||||
|
||||
contains :: Interval -> Interval -> Bool
|
||||
contains (a, b) (c, d) = a <= c && b >= d
|
||||
@@ -29,9 +29,6 @@ overlap (a, b) (c, d) = not (b < c || a > d)
|
||||
sym :: (a -> a -> Bool) -> (a -> a -> Bool)
|
||||
sym f a b = f a b || f b a
|
||||
|
||||
pairFilter :: (a -> b -> Bool) -> [(a, b)] -> [(a, b)]
|
||||
pairFilter f = filter (uncurry f)
|
||||
|
||||
part1 :: Intermediate -> Int
|
||||
part1 = count (uncurry $ sym contains)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user