Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Python by thai ( 7 years ago )
def permutations(string):
    perm_list = []

    if len(string) == 0:
        return 0
    elif len(string) == 1:
        return string
    else:
        for i in range(len(string)):
            current = string[i]
            body = string[:i] + string[i+1:]
            for j in permutations(body):
                perm = current+j
                if perm not in perm_list:
                    perm_list.append(current+j)
                else:
                   continue
    return perm_list

 

Revise this Paste

Your Name: Code Language: