Oof ouch
swlabr
For a fun 20 minutes or so, I recommend going through the recent enron “revival”. (It’s all satire)
Before reading the story I guessed that he had used chatgpt as a search engine and I was right! My best case scenario: law enforcement pushes for backdoors into chatgpt and poisons the codebase forever.
I did end up writing a code solution.
algorithm desc
So basically the problem boils down to this:
A 1 bit full adder circuit with carry in/out is described as follows:
S~i~ = X~i~ ^ Y~i~ ^ Cin~i~
Cout~i~ = (X~i~ && Y~i~) || (Cin~i~ && (X~i~ ^ Y~i~))
Where S is the output bit, X and Y are the input bits, and Cin~i~ is the carry out bit of bit i-1. For the first and last bits of the output, the circuits are slightly different due to carry in/out not mattering in the 0/last bit case.
Note that as said in the problem statement any input is correctly labelled, while outputs might be incorrect. You can then categorise each gate input/output as any of the elements in an adder circuit. You can then use set differences and intersections to determine the errors between categories. That's all you need to do!
For example, you might have something like:
X && Y = err
if this output was used correctly, it should show up as an operand to an OR gate. So if you did:
(Set of all outputs of and gates) - (Set of all inputs to or gates), if something appears, then you know one of the and gates is wrong.
Just exhaustively find all the relevant differences and intersections and you're done! To correct the circuit, you can then just brute force the 105 combinations of pair swaps to find what ends up correcting the circuit.
I did part 2 manually! I will not bother writing a code solution unless I feel like it.
well well well
AoC, so you thought you could dredge up my trauma as an EE grad by making me debug a full-adder logic circuit? How dare you. You succeeded.
thanks
I've probably learned that term at some point, so thanks for naming it. That made me realise my algorithm was too thicc and could just be greedy.
22
uh
pretty straightforward. At least it's not a grid!
21!
Finally managed to beat this one into submission.
P1
I created this disgusting mess of a recursive search that happened to work. This problem was really hard to think about due to the levels of indirection. It was also hard because of a bug I introduced into my code that would have been easy to debug with more print statements, but hubris.
P2
Recursive solution from P1 was too slow, once I was at 7 robots it was taking minutes to run the code. It didn't take long to realise that you don't really care about where the robots other than the keypad robot and the one controlling the keypad robot are since the boundary of each state needs all the previous robots to be on the A button. So with memoisation, you can calculate all the shortest paths for a given robot to each of the directional inputs in constant time, so O(kn) all up where n is the number of robots (25) and k is the complexity of searching for a path over 5 or 11 nodes.
What helped was looking at the penultimate robot's button choices when moving the keypad robot. After the first one or two levels, the transitions settle into the table in the appendix. I will not explain the code.
appendix
(P(0, 1), P(0, 1)): [],
(P(0, 1), P(0, 2)): [btn.r],
(P(0, 1), P(1, 0)): [btn.d, btn.l],
(P(0, 1), P(1, 1)): [btn.d],
(P(0, 1), P(1, 2)): [btn.d, btn.r],
(P(0, 2), P(0, 1)): [btn.l],
(P(0, 2), P(0, 2)): [],
(P(0, 2), P(1, 0)): [btn.d, btn.l, btn.l],
(P(0, 2), P(1, 1)): [btn.l, btn.d],
(P(0, 2), P(1, 2)): [btn.d],
(P(1, 0), P(0, 1)): [btn.r, btn.u],
(P(1, 0), P(0, 2)): [btn.r, btn.r, btn.u],
(P(1, 0), P(1, 0)): [],
(P(1, 0), P(1, 1)): [btn.r],
(P(1, 0), P(1, 2)): [btn.r, btn.r],
(P(1, 1), P(0, 1)): [btn.u],
(P(1, 1), P(0, 2)): [btn.u, btn.r],
(P(1, 1), P(1, 0)): [btn.l],
(P(1, 1), P(1, 1)): [],
(P(1, 1), P(1, 2)): [btn.r],
(P(1, 2), P(0, 1)): [btn.l, btn.u],
(P(1, 2), P(0, 2)): [btn.u],
(P(1, 2), P(1, 0)): [btn.l, btn.l],
(P(1, 2), P(1, 1)): [btn.l],
(P(1, 2), P(1, 2)): [],
1.1 trillion? Good luck, chuck.
21 (wip)
2 meme 2 memeious
yud, a technofascist, recently forming opinions against seed oils forms a poop ouroboros with the wellness to fascism pipeline.