Created
July 4, 2019 17:19
-
-
Save tuvo1106/7f9fbc5e7e1645ff53c53ba82746bd1e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def shell(l:list): | |
arr = l[::] | |
n = 0 | |
while (n < len(arr) // 3): | |
n = n * 3 + 1 | |
while (n > 0): | |
for i in range(int(n), len(arr)): | |
tmp = arr[i] | |
j = i | |
while j >= n and arr[j - n] > tmp: | |
arr[j] = arr[j-n] | |
j -= n | |
arr[j] = tmp | |
n = (n - 1) // 3 | |
return arr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment