Copyright | (c) Eric Mertens 2022 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
https://adventofcode.com/2022/day/23
>>>
:{
:main + ".......#......\n\ \.....###.#....\n\ \...#...#.#....\n\ \....#...##....\n\ \...#.###......\n\ \...##.#.##....\n\ \....#..#......\n" :} 110 20
Synopsis
- main :: IO ()
- sim :: Set Coord -> [Set Coord]
- step :: Set Coord -> (UArray Coord Bool -> Coord -> Maybe Coord) -> Set Coord
- isCrowded :: CoordSet -> Coord -> Bool
- moveSets :: [(Coord -> Coord, Coord -> Coord, Coord -> Coord)]
- moves :: [CoordSet -> Coord -> Maybe Coord]
- sameIx :: Ord a => [a] -> Maybe Int
- subtractFromSet :: (Foldable f, Ord a) => Set a -> f a -> Set a
- type CoordSet = UArray Coord Bool
- coordSet :: Set Coord -> CoordSet
- arrayMember :: CoordSet -> Coord -> Bool
Documentation
sim :: Set Coord -> [Set Coord] Source #
Generate an infinite list of the rounds of the elf movement rules
:: Set Coord | initial elf locations |
-> (UArray Coord Bool -> Coord -> Maybe Coord) | proposal rule |
-> Set Coord | final elf locations |
Apply a single round of the elf movement rules
isCrowded :: CoordSet -> Coord -> Bool Source #
Predicate testing to see if elf is near any other elf.
moveSets :: [(Coord -> Coord, Coord -> Coord, Coord -> Coord)] Source #
Move directions and their neighbors in the priority order of round 1
sameIx :: Ord a => [a] -> Maybe Int Source #
Find index in list where element is the same as the previous element.
type CoordSet = UArray Coord Bool Source #
A set of coordinates represented with an array for fast membership lookups