JarvisOJ Basic 爱吃培根的出题人

听说你也喜欢吃培根?那我们一起来欣赏一段培根的介绍吧:

 

bacoN is one of aMerICa'S sWEethEartS. it's A dARlinG, SuCCulEnt fOoD tHAt PaIRs FlawLE

 

什么,不知道要干什么?上面这段巨丑无比的文字,为什么会有大小写呢?你能发现其中的玄机吗?

 

提交格式:PCTF{你发现的玄机}

 

刚看到这道题时,觉得应该是数大写字母中间有多少个小写字母,进而对应ascii码表,然而我还是太年轻啊,完全不知道有培根密码这么个东西

试一试,把大写字母换成‘B’,小写字母换成‘A’,就得到了flag

吐槽一句:Google出来的培根密码解码器大多是错的,还要自己写qaq

dicc = {'AAAAA':'a','AAAAB':'b','AAABA':'c','AAABB':'d','AABAA':'e','AABAB':'f',
        'AABBA':'g','AABBB':'h','ABAAA':'i/j','ABAAB':'k','ABABA':'l','ABABB':'m',
        'ABBAA':'n','ABBAB':'o','ABBBA':'p','ABBBB':'q','BAAAA':'r','BAAAB':'s',
        'BAABA':'t','BAABB':'u/v','BABAA':'w','BABAB':'x','BABBA':'y','BABBB':'z'}
init = "bacoN is one of aMerICa'S sWEethEartS. it's A dARlinG, SuCCulEnt fOoD tHAt PaIRs FlawLE"
init = init.replace(' ','').replace('.','').replace(',','').replace("'",'')
l = len(init)
assert l%5 == 0
ans1=''
ans2=''
ans3 = []
ans4 = []
for i in init:
    if i.isupper():
        ans1 += 'A'
        ans2 += 'B'
    else:
        ans1 += 'B'
        ans2 += 'A'
for i in range(l//5):
    ans3 .append(ans1[i*5:i*5+5])
    ans4 .append(ans2[i*5:i*5+5])
for i in range(len(ans3)):
    ans3[i] = dicc[ans3[i]]
for i in range(len(ans4)):
    ans4[i] = dicc[ans4[i]]
print(''.join(ans3))
print(''.join(ans4))

 

转载于:https://www.cnblogs.com/fantasquex/p/10337863.html

你可能感兴趣的:(JarvisOJ Basic 爱吃培根的出题人)