fork download
  1. from itertools import permutations
  2.  
  3.  
  4.  
  5. def next_highest(num):
  6. perms = [''.join(p) for p in permutations(str(num))]
  7. perms = list(map(int, perms))
  8. perms = [x for x in perms if x > num]
  9. print(min(perms))
  10.  
  11. next_highest(1234)
  12. next_highest(1243)
  13. next_highest(234765)
  14. next_highest(19000)
Success #stdin #stdout 0.02s 28384KB
stdin
Standard input is empty
stdout
1243
1324
235467
90001