Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. def maxi(T):
  2.     i=0
  3.     max=T[i]
  4.     imax=i
  5.     while i<len(T):
  6.         if max<T[i]:
  7.             max=T[i]
  8.             imax=i
  9.         i+=1
  10.     return [max,imax]
  11. # print(maxi([4,3,5,2,1,6]))
  12. def tri_pancake(T):
  13.     i=0
  14.     pos=0
  15.     l=[]
  16.     while i<len(T):
  17.         tup=maxi(T[i:])
  18.         indice=tup[1]+i
  19.         if indice==len(T)-1:
  20.             l+=[i]
  21.             T=retourner(T,i)
  22.             i+=1
  23.         else:
  24.             T=retourner(T,indice)
  25.             l+=[indice]
  26.     return T,l[:-1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement