Created
October 29, 2015 17:24
-
-
Save shinespark/d9824f2dcb2791b11f5c to your computer and use it in GitHub Desktop.
昔解いたプログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
■ ウォームアップ問題 | |
コーネリア防衛軍のパイロット兼プログラマのあなたは、 | |
天才科学者Dr.アンドルフ皇帝の通信を傍受した。 | |
m7752902780q5670754954w2654637406q5286271066m8125522416a1926172574x504148223l9676431138g5289793839l5799859691n5135660909g5241613386k4148674163p2895427859i4115643171d6373795065 | |
これはどうやら、次の攻撃ターゲットの名前のようだ。 | |
以下の、これまでに解読成功した暗号文をヒントに、 | |
次の攻撃ターゲットはどこか、特定してください。 | |
暗号文 : 解読結果 | |
---------------------- | |
a0c2e4g6 : aaaa | |
a0z1c2x3 : aaaa | |
p65e68t2o51d27n48u38n13 : corneria | |
x6136494262r7484725313x185670378k2531105274x7114948063 : venom | |
■プログラミングクイズのURL | |
http://the-{ウォームアップ問題の答え}.appspot.com/ | |
■プログラミングクイズのログインコード | |
KVAMW121871691 | |
""" | |
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
import re | |
cryptogram = 'a0c2e4g6' | |
cryptogram = 'a0z1c2x3' | |
cryptogram = 'p65e68t2o51d27n48u38n13' | |
cryptogram = 'x6136494262r7484725313x185670378k2531105274x7114948063' | |
cryptogram = 'm7752902780q5670754954w2654637406q5286271066m8125522416a1926172574x504148223l9676431138g5289793839l5799859691n5135660909g5241613386k4148674163p2895427859i4115643171d6373795065' | |
re_string = re.compile('[a-z][0-9]+') | |
for chars in re_string.findall(cryptogram): | |
prefix = chars[:1] | |
remaindar = int(chars[1:]) % 26 | |
# char = ord(prefix) - remaindar | |
char = ord(prefix) + remaindar | |
# if char < 97: char += 26 # aより小さい文字だったらループ | |
if char > 122: char -= 26 # zより大きい文字だったらループ | |
# print '|%s|%s = %s - %s|' % (chars, chr(char), prefix, remaindar) | |
print '|%s|%s = %s + %s|' % (chars, chr(char), prefix, remaindar) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment