Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def download():
- with open('input.txt') as inf:
- s1=inf.readline().rstrip()
- num=int(inf.readline().rstrip())
- array=[]
- for i in range(num):
- array.append(inf.readline().rstrip())
- return s1, array, num
- def choice(string):
- numbers=[]
- for i in string:
- if i != " ":
- numbers.append(string.count(i))
- else: numbers.append(-2)
- return numbers
- def sort(numbers):
- n=len(numbers)
- big=set(numbers)
- big=list(big)
- t=0
- new=[0]*n
- while t<len(big):
- k=max(big)
- for i in range(n):
- if numbers[i]==k:
- new[i]=t
- t+=1
- big[big.index(max(big))]=0
- return new
- def space(new,string):
- array =new
- for i in range(len(string)):
- if string[i] ==" ":
- array[i] = -1
- return array
- def result(new,array):
- for i in range(len(new)):
- if new[i] == -1:
- new[i] = " "
- else:
- new[i]=array[new[i]]
- return new
- if __name__ == '__main__':
- print(download())
- print(choice(download()[0]))
- print(sort(choice(download()[0])))
- print(space(sort(choice(download()[0])),download()[0]))
- m=space(sort(choice(download()[0])),download()[0])
- g=result(m,download()[1])
- s=''
- print(s.join(g))
Add Comment
Please, Sign In to add comment