Day 24 #adventofcode in the books.
You were given a definition of a somewhat large logic circuit, and its inputs.
Part 1 was simulating the circuit and finding out what the outputs were. This was very similar to Day 7 2015, so I used the same technique - convert the "gates" to code and using eval on the list and looping till all of the output variables were defined. Worked swimmingly.
Simple. That was the feint. With part 2 the punch landed.
Part 2 you are told the circuit is an adder and four of the gates were wrongly configured, and you had to find out which inputs needed to be swapped to fix the adder.
Looked at simple brute force (iterate, try see if it fixed the adder), but turns out there are 10**19 combinations if you just do everything.
With some heuristics like it being in the path of an output, and on different paths I got that down to a paltry 260 million, but that still blew out the memory on the stack.
FINE.
Lets go work out how hardware adder works. Found a definition for a ripple adder that looked good. Created a set of integrity checks based off that and applied it to the list of gates. That worked.
[#]typescript got in the way a little in part 1 (#python would have been easier as looser variable def rules) but was great for part 2.
=> More informations about this toot | More toots from walkerb@infosec.exchange
text/gemini
This content has been proxied by September (ba2dc).