th0m45s5helby

Untitled

May 22nd, 2021
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. test=list(input().split())
  2. dic={"a":1,"b":1,"c":1,"d":2,"e":2,"f":2,"g":3,"h":3,"i":3,"j":4,"k":4,"l":4,"m":5,"n":5,"o":5,"p":6,"q":6,"r":6,"s":6,"t":7,"u":7,"v":7,"w":8,"x":8,"y":9,"z":9}
  3. A=test[2:]
  4. if test[0].isdigit():
  5.    
  6.     for _ in range(int(test[0])):
  7.         m=int(test[1])
  8.         tempdic=dict()
  9.         for i in A:
  10.             key=''
  11.             for j in i:
  12.                 key+=str(dic[j])
  13.             tempdic[int(key)]=tempdic.get(int(key),0)+1
  14.         ans=max(tempdic,key=lambda x:tempdic[x])
  15.         print(ans)
  16.  
  17. else:
  18.     A=test[2:]
  19.     tempdic=dict()
  20.     for i in A:
  21.         key=''
  22.         for j in i:
  23.             key+=str(dic[j])
  24.         tempdic[int(key)]=tempdic.get(int(key),0)+1
  25.     ans=max(tempdic,key=lambda x:tempdic[x])
  26.     print(ans)
  27.    
Advertisement
Add Comment
Please, Sign In to add comment