Untitled

mail@pastecode.io avatar
unknown
plain_text
13 days ago
1.4 kB
3
Indexable
Never
from itertools import permutations

def revrse_eng_order(strng):
    '''this function will return interger assigned for each alphabet letter'''
    a_LIST=[]
    for st in strng:
        for l in st:
            if l not in a_LIST:
                a_LIST.append(l)
                
    a_LIST.sort()
    basic_alpha="abcdefghijklmnopqrstuvwxyz"
    test_List=basic_alpha[:basic_alpha.find(a_LIST[-1])+1]
    for li in test_List:
        if li not in a_LIST:
            a_LIST.append(li)
            
    a_LIST.sort()
    #print(a_LIST)
    #print(test_List)
    p_list=list(permutations(range(12), len(a_LIST)))   #get permutated list
    new_List=[] #create a new list
    x=0
    sln=()
    
    for tp in p_list:
        #print(tp)
        s=""
        if x not in tp:
            for i in range(20):
                if i!=0:
                    for t in tp:
                        if i%t==0 :
                            s=s+a_LIST[tp.index(t)]
                            
                    if s!="":
                        new_List.append(s)
                    s=""
                    if new_List==strng:
                        break
    #print(new_List)
    #print(strng)
            if new_List==strng:
                sln=tp
                break
            new_List=[]
            
    # returns list of integers
    return list(tp)

print(revrse_eng_order(['a','b','a','a','b','a']))
Leave a Comment