Charcoal, 33 bytes
⭆θ§")∧∨⦃↧dG↓◨h↓WK"⍘+NoE...θκ§λ0§ι0ι3
Try it online! Link is to verbose version of code. Takes input as list of digit + letter pairs where the digit is 2 for Red, 1 for Blue and 0 for Black. Output is a binary string of whether each wire should be cut. Explanation:
θ Input list
⭆ Map over elements and join
"..." Compressed binary lookup table
§ Cyclically indexed by
No Count of
§ 0 First character of
ι Current entry in
... κ Prefix of
θ Input list
E Map over entries
§ 0 First character of
λ Inner entry
+ Concatenated with
ι Current entry
⍘ 3 Interpreted as base 3
Implicitly print
As an example, the last wire from the example, 0A, is the fifth black wire, therefore there are four wires in the prefix, resulting in a string 40A. This converts as 4 * 9 + 0 * 3 + A, where the letters are decoded using a=10, ... z=35, A=36, ... Z=61, resulting in a final total of 72. The use of uppercase letters here just requires the entire lookup table to be rotated by 36 bits, so it's not necessary to encode the letters.
- 184.4k
- 12
- 76
- 290