Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- def function(x):
- G = list(itertools.permutations(list(str(x))))
- G = list(set([int(''.join(i)) for i in G]))
- G.sort()
- i = G.index(x)
- if i + 1 < len(G):
- return(G[i+1])
- else:
- return(-1)
Add Comment
Please, Sign In to add comment