<jupyter_start><jupyter_text>进入正式的挑战了！--- 第一题的地址在[map.html](http://www.pythonchallenge.com/pc/def/map.html)* * 网页标题是`What about making trans?`* 题目内容是`everybody thinks twice before solving this.`和一堆乱码> g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.* 剩下的是通用tips：`要用到各种提示、尽可能挖掘数据、不要被剧透、blabla` 乍一看很无头绪，事实上题目内容就这么多，尽可能都利用起来。答案肯定就藏在这堆乱码里面。结合网页标题和图片，先尝试做几个字符转换：<jupyter_code>encoded_str = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc \
dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. \
sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."

mapping_dict = {}
mapping_dict['k'] = 'm'
mapping_dict['o'] = 'q'
mapping_dict['e'] = 'g'

decoded_str = ''.join(mapping_dict.get(c, c) for c in encoded_str)
print(decoded_str)<jupyter_output>g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr ammnsrcpq ypc dmp. bmglg gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmlg. sqglg qrpglg.myicrpylq() gq pcammmclbcb. lmu ynnjw ml rfc spj.<jupyter_text>呃，还是一堆乱码。结合这个`trans`和`map`一想，K到M是往后两个字母，O到Q是往后两个字母，E到G也是往后两个字母，那么是不是这堆乱码全部做这样的转换呢？结果如下：<jupyter_code>mapping_dict = {}
for a in range(ord('a'), ord('z') + 1):
    mapping_dict[chr(a)] = chr(a + 2)
    
decoded_str = ''.join(mapping_dict.get(c, c) for c in encoded_str)
print(decoded_str)<jupyter_output>i hope you didnt tr{nsl{te it |y h{nd. th{ts wh{t computers {re for. doing it in |y h{nd is inefficient {nd th{t's why this text is so long. using string.m{ketr{ns() is recommended. now {pply on the url.<jupyter_text>有点像那么回事了！不过有些字符不太对，仔细一看，应该是y和z要循环转成a和b。> 这里科普一下恺撒密码：> 在密码学中，恺撒密码（英语：Caesar cipher），或称恺撒加密、恺撒变换、变换加密，是一种最简单且最广为人知的加密技术。它是一种替换加密的技术，明文中的所有字母都在字母表上向后（或向前）按照一个固定数目进行偏移后被替换成密文。例如，当偏移量是3的时候，所有的字母A将被替换成D，B变成E，以此类推。这个加密方法是以罗马共和时期恺撒的名字命名的，当年恺撒曾用此方法与其将军们进行联系。>  From [baike.baidu](https://baike.baidu.com/item/%E6%81%BA%E6%92%92%E5%AF%86%E7%A0%81/4905284)<jupyter_code>mapping_dict = {}
for a in range(ord('a'), ord('y')):
    mapping_dict[chr(a)] = chr(a + 2)
mapping_dict['y'] = 'a'
mapping_dict['z'] = 'b'
    
decoded_str = ''.join(mapping_dict.get(c, c) for c in encoded_str)
print(decoded_str)<jupyter_output>i hope you didnt translate it by hand. thats what computers are for. doing it in by hand is inefficient and that's why this text is so long. using string.maketrans() is recommended. now apply on the url.<jupyter_text>翻译一下就是告诉我们不要手动一个一个字母地翻译，要使用计算机。这也是计算机的用处。还推荐我们使用`string.maketrans()`这个函数。我们完整更新下代码：（其中`string`是旧版本python的类，现在我们用`str`就可以了）<jupyter_code>intab = 'abcdefghijklmnopqrstuvwxyz'
outtab = 'cdefghijklmnopqrstuvwxyzab'
trans = str.maketrans(intab, outtab)
decoded_str = encoded_str.translate(trans)
print(decoded_str)
print('map'.translate(trans))<jupyter_output>i hope you didnt translate it by hand. thats what computers are for. doing it in by hand is inefficient and that's why this text is so long. using string.maketrans() is recommended. now apply on the url.
ocr
{'fraction_non_alphanumeric': 0.1197780678851175, 'fraction_numerical': 0.008485639686684074, 'mean_word_length': 6.350119904076738, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '290171', 'license': 'MIT', 'n_tokens_mistral': 1684, 'n_tokens_neox': 1733, 'n_words': 300, 'path': 'nbfiles/1_map.ipynb', 'repo_name': 'StevenPZChan/pythonchallenge', 'size': '3064'}