Advertisement
R1bell

antilex

Jan 20th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. def antilex(a):
  2.     pp = False
  3.     n = len(a) - 1
  4.     while True:
  5.         e = n
  6.         pos = -1
  7.         print(a)
  8.         for i in range(n):
  9.             if a[i] < a[i + 1]:
  10.                 pos = i
  11.                 pp = True
  12.         if pp == True:
  13.             while a[pos] >= a[e]:
  14.                 e -= 1
  15.             a[pos], a[e] = a[e], a[pos]
  16.             j = pos + 1
  17.             k = n
  18.             while j <= k:
  19.                 a[j], a[k] = a[k], a[j]
  20.                 k -= 1
  21.                 j += 1
  22.         else: break
  23.         pp = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement