Skip to content

Instantly share code, notes, and snippets.

@jleclanche
Created August 14, 2016 23:25
Show Gist options
  • Save jleclanche/fde0e8f6b385a472fb30eaa16b77babc to your computer and use it in GitHub Desktop.
Save jleclanche/fde0e8f6b385a472fb30eaa16b77babc to your computer and use it in GitHub Desktop.
# https://www.youtube.com/watch?v=3L-rrkyvApU :)
text = """
Ysq xaxrvl! W zsix yfi dmdxd kvaw obdvcl! A'q oxrp jwvr loifq xatt pcm wixnk mgyk mids uvtvkzby xabs, sil xabs yok rhmhzby xh wo nwll tgy ldusfbnx Jspox picvyvms. Zh'k nnlt fz'Xvxwdzs Osgz bvwfk t mokod ntvkrgkl!
Xbfe zg ksfxtywfk rhu nwdp gxvvf yim uaty, ks ahpvtmper yfi zew t lriyl hk tncl!
Tym aep rmhx, bf pcm'vx mhv tavlm tf qjevd tywk, wxgd ds s ChnTlpw qxlsruw abmh kvw takajs: "Xvxwdzs qsn trv o bikd aer A atgt dm lmfx brqc" egw I'cz zshd yfi mt pbty ggqxmhzby. Em lods hsbgt.
Sm llx pap, Gsq'l poiyarz hn fij rxqt gfgnxvt kvwvx hn ywk ghfplhwv, bgsgwjiw uy Rqlmobszcf'w kxcvbl evmimwlc. Dxeg of irx olh
Kmgveisdc, Ykeurai, Ukaergr, tgd Dolxaxw, kvw ghhlvgl hnwej cf xax iehwvgxt.
"""
alphabet = "abcdefghijklmnopqrstuvwxyz"
double = alphabet * 2
def shift_by(char, idx):
return double[alphabet.index(char) + idx]
shifts = (9, 12, 8, 22, 7, 7, 0)
if __name__ == "__main__":
i = 0
decrypted = []
for x, c in enumerate(text):
if len(text) > x+1 and text[x+1] == "!": # pull a char every exclam
continue
char = c.lower()
if char not in alphabet:
decrypted.append(c)
continue
if i == len(shifts):
i = 0
shift = shifts[i]
i += 1
if shift == -1:
continue
decrypted.append(shift_by(char, shift))
print "".join(decrypted)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment