algorithms icon indicating copy to clipboard operation
algorithms copied to clipboard

Add Bead Sort Algorithm

Open pankaj-bind opened this issue 1 year ago • 1 comments

please assign me this task

pankaj-bind avatar May 02 '24 10:05 pankaj-bind

def bead_sort(sequence):
    if any(not isinstance(i,int) or i<0 for i in sequence):
        raise TypeErro('must be posetive integer')
    
    for _ in range(len(sequence)):
        for j,(rod_upper, rod_lower) in enumerate(zip(sequence, sequence[1:])):
            print(j,(rod_upper, rod_lower) )
            if rod_upper > rod_lower:
                sequence[j] -= rod_upper - rod_lower
                sequence[j+1] += rod_upper - rod_lower
            print(f"aaaa {j} : ",sequence)        
                
    return sequence

I think it is too simple ....

SetareBehzadi avatar Aug 13 '24 12:08 SetareBehzadi