题解 | #字符串加密#

import sys

def encry(line):
    line=line.lower()
    new_line=[]
    for c in line:
        if c not in new_line:
            new_line.append(c)
    
#     print(new_line)
    
    alpha=list('abcdefghijklmnopqrstuvwxyz')
    temp=new_line.copy()
    
    for c in alpha:
        if c not in temp:
            new_line.append(c)
            
    return dict(zip(alpha, new_line))
    
    
pwd_dict={}
for i, line in enumerate(sys.stdin):
    line=line.strip()
    if i %2==0:
        pwd_dict=encry(line)
    else:
        result=[pwd_dict[c] for c in line]
        print(''.join(result))
全部评论

相关推荐

点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务