Copyright | (c) Eric Mertens 2017 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
https://adventofcode.com/2017/day/3
Day 3 asks questions about Ulam's Spiral https://en.wikipedia.org/wiki/Ulam_spiral
Documentation
Coordinates in the spiral order starting with the origin
>>>
[C 0 0,C 1 0,C 1 1,C 0 1,C (-1) 1] `Data.List.isPrefixOf` coords
True
Find manhattan distance of nth visited coordinate using 1-based counting
>>>
part1 1
0>>>
part1 12
3>>>
part1 23
2>>>
part1 1024
31
part2writes :: [Int] Source #
Infinite list of the writes done when populating the cells in spiral order by using the sum of the earlier populated neighbors.
>>>
[1,1,2,4,5,10,11,23,25,26,54,57,59,122,133,142,147,304,330,351,362,747,806] `Data.List.isPrefixOf` part2writes
True