Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
4
Task/Rot-13/Python/rot-13-1.py
Normal file
4
Task/Rot-13/Python/rot-13-1.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
>>> u'foo'.encode('rot13')
|
||||
'sbb'
|
||||
>>> 'sbb'.decode('rot13')
|
||||
u'foo'
|
||||
5
Task/Rot-13/Python/rot-13-2.py
Normal file
5
Task/Rot-13/Python/rot-13-2.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
>>> import codecs
|
||||
>>> codecs.encode("The quick brown fox jumps over the lazy dog", "rot13")
|
||||
'Gur dhvpx oebja sbk whzcf bire gur ynml qbt'
|
||||
>>> codecs.decode(_, "rot13")
|
||||
'The quick brown fox jumps over the lazy dog'
|
||||
20
Task/Rot-13/Python/rot-13-3.py
Normal file
20
Task/Rot-13/Python/rot-13-3.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
import string
|
||||
|
||||
TRANSLATION_TABLE = str.maketrans(
|
||||
string.ascii_uppercase + string.ascii_lowercase,
|
||||
string.ascii_uppercase[13:] + string.ascii_uppercase[:13] +
|
||||
string.ascii_lowercase[13:] + string.ascii_lowercase[:13]
|
||||
)
|
||||
|
||||
|
||||
def rot13(s):
|
||||
"""Return the rot-13 encoding of s."""
|
||||
return s.translate(TRANSLATION_TABLE)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
"""rot-13 encode the input files, or stdin if no files are provided."""
|
||||
import fileinput
|
||||
for line in fileinput.input():
|
||||
print(rot13(line), end="")
|
||||
15
Task/Rot-13/Python/rot-13-4.py
Normal file
15
Task/Rot-13/Python/rot-13-4.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
import string
|
||||
lets = string.ascii_lowercase
|
||||
key = {x:y for (x,y) in zip(lets[13:]+lets[:14], lets)}
|
||||
key.update({x.upper():key[x].upper() for x in key.keys()})
|
||||
encode = lambda x: ''.join((key.get(c,c) for c in x))
|
||||
if __name__ == '__main__':
|
||||
"""Peform line-by-line rot-13 encoding on any files listed on our
|
||||
command line or act as a standard UNIX filter (if no arguments
|
||||
specified).
|
||||
"""
|
||||
import fileinput
|
||||
for line in fileinput.input():
|
||||
print(encode(line), end="")
|
||||
Loading…
Add table
Add a link
Reference in a new issue