Jelly, 5(削除) 5 (削除ここまで) 4 bytes
-1 thanks to Neil!
OḂịX€OịX€
A dyadic Link accepting a list of characters, S
, on the left and a list of two lists of characters, [C, V]
, on the right which yields a list of characters.
If we could take S
as a list of 1
s and 0
s we'd have the three byte solution ịX€
.
How?
OḂịX€OịX€ - Link: S, [C,V]
O - ordinals (of S) i.e. 'C':67 'V':86
Ḃ - least significant bit 1 0
ị - index into [C,V] (vectorises) C V [Jelly indexing is 1-indexed and modular]
€ - for each:
X - random choice
Jelly, 5 bytes
OḂịX€
A dyadic Link accepting a list of characters, S
, on the left and a list of two lists of characters, [C, V]
, on the right which yields a list of characters.
If we could take S
as a list of 1
s and 0
s we'd have the three byte solution ịX€
.
How?
OḂịX€ - Link: S, [C,V]
O - ordinals (of S) i.e. 'C':67 'V':86
Ḃ - least significant bit 1 0
ị - index into [C,V] (vectorises) C V [Jelly indexing is 1-indexed and modular]
€ - for each:
X - random choice
Jelly, (削除) 5 (削除ここまで) 4 bytes
-1 thanks to Neil!
OịX€
A dyadic Link accepting a list of characters, S
, on the left and a list of two lists of characters, [C, V]
, on the right which yields a list of characters.
If we could take S
as a list of 1
s and 0
s we'd have the three byte solution ịX€
.
How?
OịX€ - Link: S, [C,V]
O - ordinals (of S) i.e. 'C':67 'V':86
ị - index into [C,V] (vectorises) C V [Jelly indexing is 1-indexed and modular]
€ - for each:
X - random choice
Jelly, 5 bytes
OḂịX€
A dyadic Link accepting a list of characters, S
, on the left and a list of two lists of characters, [C, V]
, on the right which yields a list of characters.
If we could take S
as a list of 1
s and 0
s we'd have the three byte solution ịX€
.
How?
OḂịX€ - Link: S, [C,V]
O - ordinals (of S) i.e. 'C':67 'V':86
Ḃ - least significant bit 1 0
ị - index into [C,V] (vectorises) C V [Jelly indexing is 1-indexed and modular]
€ - for each:
X - random choice
Jelly, 5 bytes
OḂịX€
A dyadic Link accepting a list of characters, S
, on the left and a list of two lists of characters, [C, V]
, on the right which yields a list of characters.
If we could take S
as a list of 1
s and 0
s we'd have the three byte solution ịX€
.
How?
OḂịX€ - Link: S, [C,V]
O - ordinals (of S) i.e. 'C':67 'V':86
Ḃ - least significant bit 1 0
ị - index into [C,V] (vectorises) C V [Jelly indexing is 1-indexed and modular]
€ - for each:
X - random choice