Skip to content

Instantly share code, notes, and snippets.

@paulmand3l
Created December 2, 2013 03:48
Show Gist options
  • Save paulmand3l/7744743 to your computer and use it in GitHub Desktop.
Save paulmand3l/7744743 to your computer and use it in GitHub Desktop.
Puzzle solving
a = 'welldone'
b = 'tinyurl.com'
def get_letter_for_number(n):
""" Return the alphabet letter for index n
>>> get_letter_for_number(1)
a
>>> get_letter_for_number(26)
z
"""
n = int(n)
assert 1 <= n <= 26, "%s is out of range" % n
return chr(n + 96)
def A(*args):
""" Convert stuff into strings
>>> A(3, 1, 20)
cat
>>> A("3-1-20")
cat
>>> A(301020)
cat
"""
if len(args) == 1:
if isinstance(args[0], str):
number_list = args[0].split('-')
elif isinstance(args[0], int):
number_list = str(args[0]).split('0')
else:
print "Error parsing input", args
else:
number_list = args
return ''.join(map(get_letter_for_number, number_list))
def I(*args):
""" Concatenate args with /
>>> I("welldone", "tinyurl.com")
tinyurl.com/welldone
"""
return '/'.join(map(str, args[::-1]))
def N(x):
return I(x, p, b)
def minus(a, b):
""" Remove exactly one copy of each character in string b from string a
>>> minus('cat', 'at')
c
>>> minus('hello', 'ol')
hel
"""
for c in b:
a = a.replace(c, '', 1)
return a
#########################
m = 83
f = 77
e = 5
g = 22
c = (m+e) - f
d = g/c
h = e-d
i = f/c
j = (d**d*c*(g+i)+1)*d*h**d*i+1
print j
############################
w = A("1-16-15-19-20-1-19-25")
v = A("9-19")
k = '-'.join([w, v])
print I(k, b) # http://rumkin.com/tools/cipher/numbers.php
p = A(j)
############################
l = '-'.join([w, p, v])
print I(l, b) # -> http://anagram-solver.net/
q = minus(w + p, v)
s = N(q)
print s
# apotasypc -> anagram-solver.net -> copypasta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment