sln_2017_03
Copyright(c) Eric Mertens 2017
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Main

Description

Synopsis

Documentation

main :: IO () Source #

coords :: [Coord] Source #

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

part1 :: Int -> Int Source #

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

part2 :: Int -> Int Source #

Returns the first value written in part 2 of the problem that is larger than the given input value.