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

Main

Description

Synopsis

Documentation

main :: IO () Source #

solve :: Vector Int -> (Int, Int) Source #

Compute both parts of Day 6

>>> solve (V.fromList [0,2,7,0])
(5,4)

findLoop :: Ord a => [a] -> (Int, Int) Source #

Computes the steps until a state repeats and also the length of the loop

>>> findLoop [1,2,3,4,5,6,7,5]
(7,3)
>>> findLoop [1,1]
(1,1)
>>> findLoop [0,1,1]
(2,1)

step :: Vector Int -> Vector Int Source #

Given a vector representing the memory banks compute the new memory bank layout.

>>> step (V.fromList [0,2,7,0])
[2,4,1,2]
>>> step (V.fromList [2,4,1,2])
[3,1,2,3]
>>> step (V.fromList [3,1,2,3])
[0,2,3,4]