def permutate_pf(v, res, l=0):
if l==len(v)-1:
res.append(v)
return
for i in range(l, len(v)):
t = []
t.append(v[i])
for j in range(len(v)):
if(j!=i):
t.append(v[j])
permutate_pf(t, res, l+1)
res = []
permutate_pf([1,2,3], res)
print(res)
ZGVmIHBlcm11dGF0ZV9wZih2LCByZXMsIGw9MCk6IAoJaWYgbD09bGVuKHYpLTE6IAoJCXJlcy5hcHBlbmQodikKCQlyZXR1cm4gCgkKCWZvciBpIGluIHJhbmdlKGwsIGxlbih2KSk6IAoJCXQgPSBbXQoJCXQuYXBwZW5kKHZbaV0pCgkJZm9yIGogaW4gcmFuZ2UobGVuKHYpKTogCgkJCWlmKGohPWkpOiAKCQkJCXQuYXBwZW5kKHZbal0pCgkJcGVybXV0YXRlX3BmKHQsIHJlcywgbCsxKQoJCQpyZXMgPSBbXQoKcGVybXV0YXRlX3BmKFsxLDIsM10sIHJlcykKCnByaW50KHJlcykK
[[2, 1, 3], [3, 1, 2], [1, 2, 3], [3, 2, 1], [1, 3, 2], [2, 3, 1]]