Day24
Copyright(c) Eric Mertens 2021
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Main

Description

https://adventofcode.com/2021/day/24

These programs were composed of 14 nearly-identical program chunks each of which varies in 3 parameters. Some of these chunks will always increase the z register and others have the potential to decrease z. Successfully validating an input will require all blocks with decrease potential to actually decrease. The pick implementation will only choose a parameter that would decrease in one of these cases.

Synopsis

Documentation

main :: IO () Source #

>>> :main
49917929934999
11911316711816

solve Source #

Arguments

:: [Int]

input digit guesses in order of preference

-> [(Int, Int, Int)]

program blocks

-> Int

first valid input

Compute the input string that satisfies the given program.

pick Source #

Arguments

:: [Int]

input digit guesses in order of preference

-> (Int, Int, Int)

block parameters

-> Int

starting z value

-> [(Int, Int)]

selected input value and resulting output z

Compute the possible input choices and resulting z from each choice.

extract :: [[String]] -> (Int, Int, Int) Source #

Extract the variable parameters from a single block. These parameters can be passed into impl to compute this effect's block on z given an input digit. Programs are comprised of one of these blocks per each digit of the input.

impl Source #

Arguments

:: Int

first parameter

-> Int

second parameter

-> Int

third parameter

-> Int

input digit

-> Int

z register

-> Int

z register

Manually compiled behavior of an input block with parameters determined by extract.