Find the (0 to 9) number in the given string of the possibilities



Problem to find number in words in the given string. And print the output in sorted order of found number.



Example-1:


Input    : s = "fighteuro"
Output   : 48 
Explain  : The string has a "eight" and "four" in number words.It's sorted order is 
           48.  


Example-2:


Input    : s = "ffoiuver"
Output   : 45
Explain  : The string has a "four" and "five" in number words.It's sorted order is 
           45.  







Solution





from itertools import permutations

s = "fighteuro"

l = [ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]

l1 = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

u = []

d1 = ""

n = ""

for i in range(3,6):

    d = list(permutations(s,i))

    k = ["".join(x) for x in d]

    for y in range(len(l)):

        if(l[y] in k):

            d1 += l[y]

            u.append(l[y])

if(sorted(d1) == sorted(s)):

    for i in range(len(u)):

        a = l.index(u[i])

        n += str(l1[a])

    n = sorted(n)

    n = "".join(n)

    print(n)

else:

    print("No")



Output



48