ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1002. Phone Numbers

Why this code in python 3 is not woking here though it is working in Jupyter Notebook ?
Posted by Prayanshu Singh 10 Apr 2020 12:17
def word_to_num(word):
    d=
{'a':'2','b':'2','c':'2','d':'3','e':'3','f':'3','g':'4','h':'4','i':'1','j':'1','k':'5','l':'5','m':'6','n':'6','o':'0','p':'7','q':'0','r':'7','s':'7','t':'8','u':'8','v':'8','w':'9','x':'9','y':'9','z':'0'}
    s=''
    for i in word:
        s+=d[i]
    return s
from itertools import permutations
while True:
    num_dict={}
    num_list=[]
    word_list=[]
    num = input()
    if num=='-1':
        break
    loop_len = int(input())
    for i in range(loop_len):
        word_list.append(input())
    for item in word_list:
        num_dict[word_to_num(item)]=item
        num_list.append(word_to_num(item))
    perm = permutations(num_list,2)
    x=0
    for k,v in list(perm):
        if k+v==num:
            print(num_dict[k]+' '+num_dict[v])
        else:
            x += 1

    if x==loop_len*(loop_len-1):
        print('No solution')