Quick actions

cmd+k|ctrl+k

Navigation

Languages

shell

Snippet info

Language

Python

Visibility

public

Author

sriram

Created

2025-05-12T11:37:10.707921Z

Updated

2025-05-12T11:37:10.707921Z

def shell(a):
    n=len(a)//2
    while n>0:
        for i in range(n,len(a)):
            key=a[i]
            k=i
            while k>=n and a[k-n]>key:
                a[k]=a[k-n]
                k=k-n
            a[k]=key
        n=n//2
        
a=[12, 34, 54, 2, 3]
result=shell(a)
print(a)
INFO