题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
import sys
import string
str1 = ""
table1 = {"1": 1, "0": 0}
table2 = {}
a = 2
for i in string.ascii_lowercase:
str1 += i
if str1 in ("pqr", "wxy"):
continue
elif len(str1) >= 3:
table1.update(dict.fromkeys(str1, a))
str1 = ""
a += 1
for i in string.ascii_uppercase:
if i == "Z":
table2[i] = "a"
else:
table2[i] = chr(ord(i.lower()) + 1)
for line in sys.stdin:
for i in line.strip():
if i in table1:
print(table1[i], end="")
continue
if i in table2:
print(table2[i],end="")
continue
else:
print(i,end="")
查看22道真题和解析
