On the Subject of Wire Sequences

JavaScript (ES6),  75 74  67 bytes

Expects a list of [color, label] pairs, using 0-2 for both. Returns a binary array describing which wires must be cut.

a=>a.map(([c,w])=>(m[c]/=8)>>w&1,m=[334844576,228136272,611931512])

Try it online!

63 bytes

We can save a few bytes by taking A=1, B=2, C=4 and returning a list of zero / non-zero values.

a=>a.map(([c,w])=>w&=m[c]/=8,m=[334844576,228136272,611931512])

Try it online!

How?

Each color is encoded as a bit mask describing the wire labels for the 1st to the 9th appearance.

 #     |  9   8   7   6   5   4   3   2   1  (0)
 Label | CBA CBA CBA CBA CBA CBA CBA CBA CBA ---
-------+-----------------------------------------
 Red   | 010 011 111 101 010 101 001 010 100 000 -> 334844576
 Blue  | 001 101 100 110 010 001 010 101 010 000 -> 228136272
 Black | 100 100 011 110 010 101 010 101 111 000 -> 611931512

Whenever a color appears, we right-shift the corresponding bit mask by 3 positions (by dividing it by 8) and we test the bit 0, 1 or 2 according to the label.


Retina 0.8.2, 119 bytes

s`(\d)(?<=(\1.*?)+)
$1$#2
%`(23|4|26|19)A|(22|1[136]|03|5|06|29)B|(2[148]|04|6|17|09)C|(07|28)[AB]|([10]2|18)[AC]|01|27

Try it online! 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 list of whether each wire should be cut. Explanation:

s`(\d)(?<=(\1.*?)+)
$1$#2

After each digit insert its cumulative appearance count.

%`(23|4|26|19)A|(22|1[136]|03|5|06|29)B|(2[148]|04|6|17|09)C|(07|28)[AB]|([10]2|18)[AC]|01|27

For each wire check whether it needs to be cut.


Rust, 89 bytes

|w|w.scan([0;3],|a,&(c,l)|{a[c]+=1;Some(b"TGjEQBMERBuFgCkDJD"[2*a[c]-2+c/2]>>c%2*3+l&1)})

Try it online!

Explanation:

Both colors and labels are encoded as numbers from 0-2. The output is a number for every wire: 1 if it should be cut, 0 otherwise. The b"TG...D" string contains a binary encoding of the above table. The labels to be cut in every cell is transformed into a 3-bit mask. Three of these masks can be packed into two bytes (Red and Blue in the first byte and Black in the second byte). The 6-th bit (which is unused) is also set, to make all the characters ASCII printable (to not need escape sequences or raw strings).

Tags:

Code Golf