Copyright | (c) Eric Mertens 2022 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
https://adventofcode.com/2022/day/15
>>>
:{
:main + "part 1 override 10 part 2 override 20\n\ \Sensor at x=2, y=18: closest beacon is at x=-2, y=15\n\ \Sensor at x=9, y=16: closest beacon is at x=10, y=16\n\ \Sensor at x=13, y=2: closest beacon is at x=15, y=3\n\ \Sensor at x=12, y=14: closest beacon is at x=10, y=16\n\ \Sensor at x=10, y=20: closest beacon is at x=10, y=16\n\ \Sensor at x=14, y=17: closest beacon is at x=10, y=16\n\ \Sensor at x=8, y=7: closest beacon is at x=2, y=10\n\ \Sensor at x=2, y=0: closest beacon is at x=2, y=10\n\ \Sensor at x=0, y=11: closest beacon is at x=2, y=10\n\ \Sensor at x=20, y=14: closest beacon is at x=25, y=17\n\ \Sensor at x=17, y=20: closest beacon is at x=21, y=22\n\ \Sensor at x=16, y=7: closest beacon is at x=15, y=3\n\ \Sensor at x=14, y=3: closest beacon is at x=15, y=3\n\ \Sensor at x=20, y=1: closest beacon is at x=15, y=3\n" :} 26 56000011
Synopsis
- type Input = [(Int, Int, Int, Int)]
- main :: IO ()
- data Sensor = Sensor Coord Int
- inputSensors :: Input -> [(Sensor, Coord)]
- part1 :: Int -> [Sensor] -> [Coord] -> Int
- rowSlice :: Int -> Sensor -> [Box' 1]
- part2 :: Int -> [Sensor] -> Int
- boxCorner :: Box' 2 -> Coord
- diamondBox :: Sensor -> Box' 2
- subtractAllOf :: forall (n :: Nat). [Box n] -> [Box n] -> [Box n]
- cover :: forall (n :: Nat). Int -> Int -> Box n -> Box ('S n)
Documentation
inputSensors :: Input -> [(Sensor, Coord)] Source #
Convert input data into a list of sensors and beacon coordinates
:: Int | y value of row |
-> [Sensor] | sensors |
-> [Coord] | beacons |
-> Int | locations in row that can't contain a sensor |
Compute the number of locations in a given row that can't contain a sensor.
Generate the 1-d box describing the X region covered by the sensor at a given Y value
Find the tuning frequency of the only location in the given region that could contain an undiscovered beacon.
diamondBox :: Sensor -> Box' 2 Source #
Covert a diamond centered at a coordinate with a radius into a square region.
Remove the first list of regions from the second.