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

Main

Description

https://adventofcode.com/2017/day/13

Day 13 asks us questions about packets traveling through a periodic scanner.

Synopsis

Documentation

type Scanners = [(Int, Int)] Source #

The scanners are represented by a pair of the number of time units it will take a packet to reach that scanner and the number of cells the scanner traverses.

main :: IO () Source #

Compute the solutions to day 13. Input can be ovverridden via command-line arguments.

collides Source #

Arguments

:: Int

time step

-> Int

scanner depth

-> Bool 

Returns true when the scanner will be at position 0 at the given time-step.

>>> collides 6 4
True
>>> collides 5 4
False

part1 :: Scanners -> Int Source #

Sum of the product of index and size of scanners that detect the packet.

>>> part1 [(0,3),(1,2),(4,4),(6,4)]
24

part2 :: Scanners -> Maybe Int Source #

Finds the smallest offset at which time a packet could traverse the scanners without collision.

>>> part2 [(0,3),(1,2),(4,4),(6,4)]
Just 10

safeStart Source #

Arguments

:: Scanners 
-> Int

delay

-> Bool 

Check that a packet delayed by a certain amount of time will successfully clear the scanners.