Expand description
This is my solution for Advent of Code - Day 17: Chronospatial Computer
parse_input
parses the input into a Computer
.
Computer::run
run solves part 1, with helpers Computer::next_instruction
, and Computer::deref_combo
.
There is also a method for each of the 8 operators.
reverse_engineer_quine
solves part 2 by building up the number for a from least-significant digit backwards
brute_force_quine
is left as deaf code for posterity
StructsΒ§
- Computer πRepresents a computer and the program it will run
FunctionsΒ§
- brute_
force_ πquine Look for a quine by trying all values of A from 0 - parse_
input πParse the puzzle input, three registers, a blank line and a program represented by a list of 3-bit digits - parse_
program πParse e.g.Program: 2,0,2,4
intovec![2,0,2,4]
- parse_
register πParse e.g.Register A: 2024
into2024usize
- Working from least-significant bit backwards build a bit at a time. This relies on the program having a loop where a 3-bit digit is right-shifted off the A register and corresponding single digit is outputted by the program.
- The entry point for running the solutions with the βrealβ puzzle input.