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])
63 bytes
Or 63 bytesWe can save a few bytes by taking A=1, B=2, C=4 and outputtingreturning a list of zero / non-zero values.
a=>a.map(([c,w])=>w&=m[c]/=8,m=[334844576,228136272,611931512])
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.
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])
Or 63 bytes by taking A=1, B=2, C=4 and outputting a list of zero / non-zero values.
a=>a.map(([c,w])=>w&=m[c]/=8,m=[334844576,228136272,611931512])
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.
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])
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])
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.
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])
Or 63 bytes by taking A=1, B=2, C=4 and outputting a list of zero / non-zero values.
a=>a.map(([c,w])=>w&=m[c]/=8,m=[334844576,228136272,611931512])
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.
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])
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.
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])
Or 63 bytes by taking A=1, B=2, C=4 and outputting a list of zero / non-zero values.
a=>a.map(([c,w])=>w&=m[c]/=8,m=[334844576,228136272,611931512])
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.
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])
How?
Each color is encoded as a bit mask describing the wire labels for the 1st to the 9th appearance.
For Red, this gives:
# | 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.
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])
How?
Each color is encoded as a bit mask describing the wire labels for the 1st to the 9th appearance.
For Red, this gives:
9 8 7 6 5 4 3 2 1 (0)
CBA CBA CBA CBA CBA CBA CBA CBA CBA ---
010 011 111 101 010 101 001 010 100 000 -> 334844576
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.
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])
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.