给定纯文本和可能的密码文本,确定是否可以使用所述方案从纯文本形成密码文本

2024-09-30 00:40:58 发布

您现在位置:Python中文网/ 问答频道 /正文

字母表被列举为A=0,B=1,C=2,Z=25。考虑加密方案,其中在明文中具有值CI的字符被另一个具有值Cj的字符替换,使用公式CJ=(CI + 5)% 26。替换后,结果字符串随机洗牌(排列)以获得密码文本

给定纯文本和可能的密码文本,您的任务是确定是否可以使用上述方案从纯文本生成密码文本

(假设所有字符串均为大写)

输入格式:

输入的第一行包含一个表示纯文本的字符串

输入的第二行是一个字符串,表示可能的密文

输出格式:

显示是或否(输出后无换行符)

例如:

输入:

Python TDMSUY

输出:

输入:

乔普内尔 JQYVSUTHO

输出:

没有

请用Python回答


Tags: 字符串文本ci密码格式方案字符字母表
2条回答

IPYNB Formatted Code Here

s = input()
p = input()
#s = s[::-1]
t = ''
for c in s:
  t+=chr((ord(c)+5-ord('A'))%26 + ord('A'))
  

def removeSpaces(string): 
    string = string.replace(' ','') 
    string = string.replace(',','')
    return string.lower()
def check(t, p):
     
    # the sorted strings are checked 
    if(sorted(t)== sorted(p)):
        print("Yes",end='') 
    else:
        print("No",end='')         
         
check(t, p)
a=input()
d={}
for i in a:
  d[chr(((ord(i)-60)%26)+65)]=d.get(chr(((ord(i)-60)%26)+65),0)+1
b=input()
for i in b:
  if d.get(i,0)<=0:
    print("No",end="")
    break
  d[i]-=1
else:
  print("Yes",end="")

相关问题 更多 >

    热门问题