summaryrefslogtreecommitdiff
path: root/4b.py
blob: a9b631b6ecc6a4daba54ad1cf39c8df88d78fa4e (plain)
1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/env python3

import sys, re, functools

encr=filter(lambda t:"".join(x[1] for x in sorted([(len(p[0]),p[1]) for p in re.findall(r"((.)\2*)","".join(sorted(t[0].replace("-",""))))],key=lambda t:(-t[0],t[1]))[:5])==t[2],[re.match(r"([-a-z]+)-(\d+)\[([a-z]+)\]",r).groups() for r in sys.stdin.read().split("\n")[:-1]])

decr=[("".join(" " if c=="-" else "".join(chr(x) for x in range(97,123))[(ord(c)-97+int(r[1]))%26] for c in r[0]),r[1]) for r in encr]

found=next(r for r in decr if r[0].find("northpole")!=-1)[1]

print(found)