def ajout(nb, sens): global total for c in range(1,10): if c in nb: continue if not nb: ajout([c], 0) else: prev = nb[-1] v = (c > prev and sens >= 0) - (c < prev) if v: ajout(nb + [c], v) total += 1 total = -1 ajout([], 0) print(total)
Create, edit, and import your Python scripts
def ajout(nb, sens): global total for c in range(1,10): if c in nb: continue if not nb: ajout([c], 0) else: prev = nb[-1] v = (c > prev and sens >= 0) - (c < prev) if v: ajout(nb + [c], v) total += 1 total = -1 ajout([], 0) print(total)