Day05
Copyright(c) Eric Mertens 2021
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Main

Description

https://adventofcode.com/2021/day/5

The input is a bunch of segments; count intersections.

Synopsis

Documentation

main :: IO () Source #

>>> :main
8060
21577

solve :: [(Int, Int, Int, Int)] -> Int Source #

Compute the number of points covered by more than one segment

isStraight :: (Int, Int, Int, Int) -> Bool Source #

Predicate for straight segments

points :: (Int, Int, Int, Int) -> [(Int, Int)] Source #

Enumerate the points contained in a segment

>>> points (1,1,1,3)
[(1,1),(1,2),(1,3)]
>>> points (9,7,7,7)
[(9,7),(8,7),(7,7)]
>>> points (1,1,3,3)
[(1,1),(2,2),(3,3)]
>>> points (9,7,7,9)
[(9,7),(8,8),(7,9)]

range :: Int -> Int -> [Int] Source #

Inclusive enumeration of the integers between two bounds

>>> range 3 5
[3,4,5]
>>> range 9 9
[9]
>>> range 7 1
[7,6,5,4,3,2,1]