diff options
Diffstat (limited to 'progs/a504.py')
-rw-r--r-- | progs/a504.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/progs/a504.py b/progs/a504.py new file mode 100644 index 0000000..fac440a --- /dev/null +++ b/progs/a504.py @@ -0,0 +1,8 @@ +def pancake_sort(nums):
+ arr_len = len(nums)
+ while arr_len > 1:
+ mi = nums.index(max(nums[0:arr_len]))
+ nums = nums[mi::-1] + nums[mi+1:len(nums)]
+ nums = nums[arr_len-1::-1] + nums[arr_len:len(nums)]
+ arr_len -= 1
+ return nums
\ No newline at end of file |