I have some chars, for example [“ab”], and I just have two number, zero and one.
And I want to get an answer like
[[('a', 1), ('b', 1)],
[('a', 0), ('b', 1)],
[('a', 1), ('b', 0)],
[('a', 0), ('b', 0)]]
I am a beginner, could someone help me?
Thankyou very much.
The most interesting part is generating the list of all possible sequences of
0and1; one way is viareplicateM:You can use
mapandzipfrom there:To match your answer exactly, you’d have to do a tiny bit of extra munging: