Cut : non-zero (falseytruthy)
Don't cut : zero (truthyfalsey)
Cut : non-zero (falsey)
Don't cut : zero (truthy)
Cut : non-zero (truthy)
Don't cut : zero (falsey)
Jelly, (削除) 27 (削除ここまで) 2625 bytes
ċṪ$Ƥżḅ3Ʋị"μỵƓṢ4ż]¶:ɼ’ḃ7¤&Tɼ’ḃ7¤&
A dyadic Link accepting a list of the wire colours on the left and a list of the wire labels on the right which yields a list of wire numbersindicators of whether to cut each wire.
Red Red : 1 A : 1
Blue : 2 B : 2
Black : 3 C : 4Outputs:
Cut : non-zero (falsey)
Don't cut : zero (truthy)
Here Here is an easier to use version accepting the colours, RBK (red, blue, black), on the first line and the labels, ABC on the second line, which yields a list of wire numbers to cut.
ċṪ$Ƥżḅ3Ʋị"...’ḃ7¤&T’ḃ7¤& - Link: colours, labels
Ʋ - last four links as a monad - f(colours):
Ƥ - for prefixes:
$ - last two links as a monad - f(prefix):
Ṫ - tail -> current wire's colour
ċ - count -> number of such wires seen before
ż - zip with (colours)
3 - three
ḅ - convert (zip result items) from base (3)
X = the indexes to check in the flattened table
¤ - nilad followed by link(s) as a nilad:
"...’ - 41650313607423351764917
7 - seven
ḃ - bijective-base -> [4,2,7,2,5,5,1,2,2,5,1,5,2,2,2,5,6,6,7,4,3,3,5,4,2,1,4]
Y = the flattened table as bitmasks of labels to cut
ị - (each of X) index into (Y)
& - (each of that) bitwise AND with (labels) T - truthy indices(vectorises)
Jelly, (削除) 27 (削除ここまで) 26 bytes
ċṪ$Ƥżḅ3Ʋị"μỵƓṢ4ż]¶:ɼ’ḃ7¤&T
A dyadic Link accepting a list of the wire colours on the left and a list of the wire labels on the right which yields a list of wire numbers to cut.
Red 1 A 1
Blue 2 B 2
Black 3 C 4
Here is an easier to use version accepting the colours, RBK (red, blue, black), on the first line and the labels, ABC on the second line.
ċṪ$Ƥżḅ3Ʋị"...’ḃ7¤&T - Link: colours, labels
Ʋ - last four links as a monad - f(colours):
Ƥ - for prefixes:
$ - last two links as a monad - f(prefix):
Ṫ - tail -> current wire's colour
ċ - count -> number of such wires seen before
ż - zip with (colours)
3 - three
ḅ - convert (zip result items) from base (3)
X = the indexes to check in the flattened table
¤ - nilad followed by link(s) as a nilad:
"...’ - 41650313607423351764917
7 - seven
ḃ - bijective-base -> [4,2,7,2,5,5,1,2,2,5,1,5,2,2,2,5,6,6,7,4,3,3,5,4,2,1,4]
Y = the flattened table as bitmasks of labels to cut
ị - (each of X) index into (Y)
& - (each of that) bitwise AND with (labels) T - truthy indices
Jelly, (削除) 27 (削除ここまで) 25 bytes
ċṪ$Ƥżḅ3Ʋị"μỵƓṢ4ż]¶:ɼ’ḃ7¤&
A dyadic Link accepting a list of the wire colours on the left and a list of the wire labels on the right which yields a list of indicators of whether to cut each wire.
Red : 1 A : 1
Blue : 2 B : 2
Black : 3 C : 4Outputs:
Cut : non-zero (falsey)
Don't cut : zero (truthy)
Here is an easier to use version accepting the colours, RBK (red, blue, black), on the first line and the labels, ABC on the second line, which yields a list of wire numbers to cut.
ċṪ$Ƥżḅ3Ʋị"...’ḃ7¤& - Link: colours, labels
Ʋ - last four links as a monad - f(colours):
Ƥ - for prefixes:
$ - last two links as a monad - f(prefix):
Ṫ - tail -> current wire's colour
ċ - count -> number of such wires seen before
ż - zip with (colours)
3 - three
ḅ - convert (zip result items) from base (3)
X = the indexes to check in the flattened table
¤ - nilad followed by link(s) as a nilad:
"...’ - 41650313607423351764917
7 - seven
ḃ - bijective-base -> [4,2,7,2,5,5,1,2,2,5,1,5,2,2,2,5,6,6,7,4,3,3,5,4,2,1,4]
Y = the flattened table as bitmasks of labels to cut
ị - (each of X) index into (Y)
& - (that) bitwise AND with (labels) (vectorises)
ċṪ$Ƥżḅ3Ʋị"...’ḃ7¤&T - Link: colours, labels
Ʋ - last four links as a monad - f(colours):
Ƥ - for prefixes:
$ - last two links as a monad - f(prefix):
Ṫ - tail -> current wire's colour
ċ - count -> number of such wires seen before
ż - zip with (colours)
3 - three
ḅ - convert (zip result items) from base (3)
X = the indexindexes to check in the flattened table
¤ - nilad followed by link(s) as a nilad:
"...’ - 41650313607423351764917
7 - seven
ḃ - bijective-base -> [4,2,7,2,5,5,1,2,2,5,1,5,2,2,2,5,6,6,7,4,3,3,5,4,2,1,4]
Y = the flattened table as bitmasks of labels to cut
ị - (each of X) index into (Y)
& - (each of that) bitwise AND with (labels)
T - truthy indices
ċṪ$Ƥżḅ3Ʋị"...’ḃ7¤&T - Link: colours, labels
Ʋ - last four links as a monad - f(colours):
Ƥ - for prefixes:
$ - last two links as a monad - f(prefix):
Ṫ - tail -> current wire's colour
ċ - count -> number of such wires seen before
ż - zip with (colours)
3 - three
ḅ - convert (zip result items) from base (3)
X = the index to check in the flattened table
¤ - nilad followed by link(s) as a nilad:
"...’ - 41650313607423351764917
7 - seven
ḃ - bijective-base -> [4,2,7,2,5,5,1,2,2,5,1,5,2,2,2,5,6,6,7,4,3,3,5,4,2,1,4]
Y = the flattened table as bitmasks of labels to cut
ị - (each of X) index into (Y)
& - (each of that) bitwise AND with (labels)
T - truthy indices
ċṪ$Ƥżḅ3Ʋị"...’ḃ7¤&T - Link: colours, labels
Ʋ - last four links as a monad - f(colours):
Ƥ - for prefixes:
$ - last two links as a monad - f(prefix):
Ṫ - tail -> current wire's colour
ċ - count -> number of such wires seen before
ż - zip with (colours)
3 - three
ḅ - convert (zip result items) from base (3)
X = the indexes to check in the flattened table
¤ - nilad followed by link(s) as a nilad:
"...’ - 41650313607423351764917
7 - seven
ḃ - bijective-base -> [4,2,7,2,5,5,1,2,2,5,1,5,2,2,2,5,6,6,7,4,3,3,5,4,2,1,4]
Y = the flattened table as bitmasks of labels to cut
ị - (each of X) index into (Y)
& - (each of that) bitwise AND with (labels)
T - truthy indices