差分
[[Python]]による[[シーザー暗号]]([[カエサル暗号]])の記述例。
== 記述例1 ==
[[The Zen of Python]]の[[ソースコード]]から抜粋し関数化したもの。絶対に[[The Zen of Python]]のオリジナルのソースコードを見ておくこと。シフト数は13に固定されており、いわゆる[[ROT13]]となっている。
<source lang="csharp">
def caeser_decode(text):
d = {}
for c in (65, 97):
for i in range(26):
d[chr(i+c)] = chr((i+13) % 26 + c)
return "".join([d.get(c, c) for c in text])
</source>
== 関連項目 ==
* [[Python]]
* [[シーザー暗号]]
== 参考文献 ==
<references/>
== 外部リンク ==
{{stub}}
== 記述例1 ==
[[The Zen of Python]]の[[ソースコード]]から抜粋し関数化したもの。絶対に[[The Zen of Python]]のオリジナルのソースコードを見ておくこと。シフト数は13に固定されており、いわゆる[[ROT13]]となっている。
<source lang="csharp">
def caeser_decode(text):
d = {}
for c in (65, 97):
for i in range(26):
d[chr(i+c)] = chr((i+13) % 26 + c)
return "".join([d.get(c, c) for c in text])
</source>
== 関連項目 ==
* [[Python]]
* [[シーザー暗号]]
== 参考文献 ==
<references/>
== 外部リンク ==
{{stub}}