All permutations

Write permutations(items) that returns every ordering of the list of distinct values, as a list of lists. Order of the results does not matter.

permutations([1, 2, 3])  ->  [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
permutations([])         ->  [[]]

The point is to practise backtracking with a used marker that is undone after each recursive call.

def permutations(items):
    ...