Safe HaskellNone

Day09

Description

General - Get a/the list of numbers. Set the length of the preamble (P). Push a window of length P over the list and check the next number (by calcing the sum of pairs until we find a match).

Part 1 - Calc the pairs recursively.

Part 2 - Use part1 to find the invalidNumber and then (recursively) push a window over the input to find the encryption weakness.

Synopsis

Documentation

data XMAS #

The length of the preamble and the numbers.

Constructors

XMAS Int [Int] 

input :: String -> XMAS #

Read the input file.

check :: [Int] -> Int -> Bool #

Return true, if there is at least one valid pair.

part1 :: XMAS -> Int #

Solve part1.

findEncryptionWeakness :: Int -> [Int] -> (Bool, [Int]) #

Return the encryption weakness.

part2 :: XMAS -> Int #

Solve part2.