题解 | #字符串加密#

字符串加密

http://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3

** 踩坑指南:大写和小写要分别去重和放首位,大写的提取key之后,剩下的大写依次往后排。 小写的提取key后,剩下的小写字母依次往后排。 26个大写字母放前面,26个小写字母放后面,对应位置进行替换输出。 **

s = input()
s2 = input()
lower_list = []
upper_list = []
for x in s:
	if x >= "A" and x <= "Z" and x not in upper_list:
		upper_list.append(x)
	elif x >= "a" and x <= "z" and x not in lower_list:
		lower_list.append(x)

all_list_p1 = [chr(i) for i in range(65,128) if chr(i) >= 'A' and chr(i) <= 'Z']
all_list_p2 = [chr(i) for i in range(65,128) if chr(i) >= 'a' and chr(i) <= 'z']
all_list = all_list_p1 + all_list_p2

all_list2_lower = [x for x in all_list_p2 if x not in lower_list]
all_list2_upper = [x for x in all_list_p1 if x not in upper_list]
all_list3 = upper_list + all_list2_upper + lower_list + all_list2_lower
# print(all_list3)

result_list = []
for x in s2:
	result_list.append(all_list3[all_list.index(x)])
print("".join(result_list))
全部评论

相关推荐

程序员牛肉:主要是因为小厂的资金本来就很吃紧,所以更喜欢有实习经历的同学。来了就能上手。 而大厂因为钱多,实习生一天三四百的就不算事。所以愿意培养你,在面试的时候也就不在乎你有没有实习(除非是同级别大厂的实习。) 按照你的简历来看,同质化太严重了。项目也很烂大街。 要么换项目,要么考研。 你现在选择工作的话,前景不是很好了。
点赞 评论 收藏
分享
刘湘_passion:太强了牛肉哥有被激励到
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务