I got the following problem. Given a word (a binary one) I want to generate all the combinations with length n
, and the given word can not be a prefix of any of the combinations.
For instance, with n = 3
and the word is 00
I would like to generate:
010
011
100
101
110
111
Is there any pythonic way to do this?
Edit: Sorry, I am trying modifications of this standard pseudo-code
combinations:
if depth = 0 return result
for i in start..size
out+=combinations(depth-1, i+1, result)
return out
I can't figure out how to add the restriction of not starting by the given word. By "pythonic" I mean with something like comprehension lists, or a beautiful one-liner :D