I have the following recursion method:
def permute(instr, idx): if \'X\' not in instr: yield \'\'.join(instr) for i in range(idx, len(instr))