Copyright | (c) Eric Mertens 2023 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
https://adventofcode.com/2023/day/18
Computes the area of the described polynomial using the https://en.wikipedia.org/wiki/Shoelace_formula.
The extra perimeter factor accounts for the path that is being described as having its own area. Each unit of the path is a 1x1 square. There will always been as many top and left perimeter edges as bottom and right edges, but only (for example) the top and left edges will be contained in the polygon. Half the perimeter accounts for the squares that hang off the bottom and right. An extra one unit accounts for the missed square at the bottom-right of the polygon.
>>>
:{
:main + "R 6 (#70c710) D 5 (#0dc571) L 2 (#5713f0) D 2 (#d2c081) R 2 (#59c680) D 2 (#411b91) L 5 (#8ceee2) U 2 (#caa173) L 1 (#1b58a2) U 2 (#caa171) R 2 (#7807d2) U 3 (#a77fa3) L 2 (#015232) U 2 (#7a21e3) " :} 62 952408144115