[[練習問題]]

 a = 'abcdefghijklmnopqrstuvwxyz .,-'
 s = 'qdq-gi.q-a ziatmxxitmdqibtqi-ustbi ri.qmoqrcxi.qbubu zir -ibtqi-qp-qaai ripmymsqkir -ibtqi-qy dmxi ri.cnxuoi rruoumxakir -ibtqiqzmobyqzbkii-q.qmxi -imyqzpyqzbi rixmeaki -puzmzoqai -i-qscxmbu zaimzpir -i btq-iymbbq-a;iz -iatmxximzgi.q-a zinqiuzimzgiemgipuao-uyuzmbqpimsmuzabir -ia. za -uzsiacotiimi.qbubu zj'
 for i in xrange(1, len(a)):
   candidate = ''
   for e in s:
     if e == ';':
       candidate += ';'
     else:
       candidate += a[(a.find(e) + i) % len(a)]
   if 'person' in candidate:
     print candidate
     break
 for i in xrange(len(a)):
     candidate = ''.join(';' if e==';' else a[(a.find(e) + i) % len(a)] for e in s)
     if 'person' in candidate:
         print candidate

#初心者用

 # coding:utf-8
 
 A = "abcdefghijklmnopqrstuvwxyz .,-abcdefghijklmnopqrstuvwxyz .,-"
 B = "qdq-gi.q-a ziatmxxitmdqibtqi-ustbi ri.qmoqrcxi.qbubu zir -ibtqi-qp-qaai ripmymsqkir -ibtqi-qy dmxi ri.cnxuoi rruoumxakir -ibtqiqzmobyqzbkii-q.qmxi -imyqzpyqzbi rixmeaki -puzmzoqai -i-qscxmbu zaimzpir -i btq-iymbbq-a;iz -iatmxximzgi.q-a zinqiuzimzgiemgipuao-uyuzmbqpimsmuzabir -ia. za -uzsiacotiimi.qbubu zj"
 G = []
 
 for i in range(len(A)):
	 G.append(A[i:i + 1])
 
 L = ["p", "e", "r", "s", "o", "n"]
 for k in range(1,len(A)/2):
	 N = ""
	 for q in range(len(L)):
		 w = G.index(L[q])
		 N += G[w + k]
	 if N in B:
		 C = []
		 H = ""
		 for t in range(len(B)):
			 C.append(B[t:t + 1])
		 for y in range(len(B)):
			 if C[y] == ";":
				 H += ";"
			 else:
				 v = G.index(C[y])
				 H += G[v - k]
		 print H

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS