forked from pushingice/scavenger-hunt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next_clue.py
executable file
·7 lines (5 loc) · 3.18 KB
/
next_clue.py
1
2
3
4
5
6
7
#!/usr/bin/env python3
from base64 import b64decode
# Please do the lab legitimately - if you need help, just ask us!
exec(b64decode("""aW1wb3J0IG9zCmltcG9ydCBzeXMKaW1wb3J0IHJhbmRvbQppbXBvcnQgaGFzaGxpYgppbXBvcnQgZ2VuZXJhdGVfY2x1ZXMgYXMgZ2MKaW1wb3J0IHN1YnByb2Nlc3MgYXMgc3AKCgpkZWYgc2hlbGxfb3V0KGNvbW0pOgogICAgcmV0dXJuIHNwLnJ1bihjb21tLnNwbGl0KCksIGNhcHR1cmVfb3V0cHV0PVRydWUpLnN0ZG91dC5kZWNvZGUoKQoKCmRlZiBjaGVja19oaW50KGNsdWUsIGhpbnQsIGRpY3Rpb25hcnkpOgogICAgaWYgY2x1ZSA9PSAzOgogICAgICAgIGNvdW50ID0gbGVuKG9zLmxpc3RkaXIoIi91c3IiKSkKICAgICAgICByZXR1cm4gaW50KGhpbnQpID09IGNvdW50CiAgICBlbGlmIGNsdWUgPT0gNDoKICAgICAgICBob3N0bmFtZSA9IG9wZW4oIi9ldGMvaG9zdG5hbWUiLCAiciIpLnJlYWQoKS5zdHJpcCgpCiAgICAgICAgcmV0dXJuIGhpbnQgPT0gaG9zdG5hbWUKICAgIGVsaWYgY2x1ZSA9PSA1OgogICAgICAgIHJldHVybiBoaW50IGluIFsiaSIsICJuIiwgIi1pIiwgIi1uIl0KICAgIGVsaWYgY2x1ZSA9PSA2OgogICAgICAgIHJldHVybiBoaW50ID09IG9zLmdldGVudigiUEFUSCIpLnNwbGl0KCI6IilbLTFdCiAgICBlbGlmIGNsdWUgPT0gNzoKICAgICAgICByZXR1cm4gaGludCA9PSBzaGVsbF9vdXQoIndoaWNoIHB5dGhvbiIpLnN0cmlwKCkKICAgIGVsaWYgY2x1ZSA9PSA4OgogICAgICAgIHJldHVybiBoaW50IGluIFsiYWNjZWwiXQogICAgZWxpZiBjbHVlID09IDk6CiAgICAgICAgdmFsID0gc2hlbGxfb3V0KGYid2MgLWwge2RpY3Rpb25hcnl9Iikuc3BsaXQoKVswXQogICAgICAgIHJldHVybiBoaW50ID09IHZhbAogICAgZWxpZiBjbHVlID09IDEwOgogICAgICAgIHJldHVybiAoCiAgICAgICAgICAgIGhpbnQgPT0gc2hlbGxfb3V0KGYiZ3JlcCAtQSAxIHRhY3RmdWwge2RpY3Rpb25hcnl9Iikuc3RyaXAoKS5zcGxpdCgiXG4iKVsxXQogICAgICAgICkKICAgIGVsaWYgY2x1ZSA9PSAxMjoKICAgICAgICB3aXRoIG9wZW4oIlJFQURNRS5tZCIsICJyIikgYXMgZjoKICAgICAgICAgICAgcmV0dXJuICJjYXRzIGFyZSBiZXR0ZXIgdGhhbiBkb2dzIiBpbiAiIi5qb2luKGYucmVhZGxpbmVzKCkpCiAgICBlbGlmIGNsdWUgPT0gMTE6CiAgICAgICAgaWYgbm90IGhpbnQuc3RhcnRzd2l0aCgiLSIpOgogICAgICAgICAgICByZXR1cm4gRmFsc2UKICAgICAgICBpZiBub3QgKCJrIDUiIGluIGhpbnQgb3IgIms1IiBpbiBoaW50KToKICAgICAgICAgICAgcmV0dXJuIEZhbHNlCiAgICAgICAgaWYgbm90ICJyIiBpbiBoaW50OgogICAgICAgICAgICByZXR1cm4gRmFsc2UKICAgICAgICBpZiBub3QgKCJuIiBpbiBoaW50IG9yICJnIiBpbiBoaW50KToKICAgICAgICAgICAgcmV0dXJuIEZhbHNlCiAgICAgICAgcmV0dXJuIFRydWUKCgppZiBfX25hbWVfXyA9PSAiX19tYWluX18iOgoKICAgIGlmIGxlbihzeXMuYXJndikgIT0gMzoKICAgICAgICBzeXMuZXhpdCgiTmVlZCBhIGNsdWUgbnVtYmVyIGFuZCBoaW50IikKICAgIGNsdWVfbnVtYmVyID0gaW50KHN5cy5hcmd2WzFdKQogICAgaGludCA9IHN5cy5hcmd2WzJdCiAgICB0cnk6CiAgICAgICAgd2l0aCBvcGVuKCIuc2VjcmV0X251bWJlciIsICJyIikgYXMgZjoKICAgICAgICAgICAgc2VjcmV0X251bWJlciA9IGludCgiIi5qb2luKGYucmVhZGxpbmVzKCkpKQogICAgZXhjZXB0OgogICAgICAgIHN5cy5leGl0KCJHZW5lcmF0ZSB0aGUgY2x1ZXMgZmlyc3QhIikKCiAgICBjbHVlX2luZGV4ZXMgPSBnYy5nZW5fY2x1ZV9saXN0KAogICAgICAgIGdjLlNUQVJUX0NMVUUsIGdjLkxBU1RfQ0xVRSwgZ2MuQ0xVRV9TUEFDRSwgc2VjcmV0X251bWJlcgogICAgKQogICAgZGljdGlvbmFyeSA9IG9wZW4oImNvbmYiLCAiciIpLnJlYWQoKS5zdHJpcCgpCgogICAgaWYgY2hlY2tfaGludChjbHVlX251bWJlciwgaGludCwgZGljdGlvbmFyeSk6CiAgICAgICAgcHJpbnQoZ2MuemVyb19wYWQoY2x1ZV9pbmRleGVzW2NsdWVfbnVtYmVyIC0gZ2MuU1RBUlRfQ0xVRV0pKQogICAgZWxzZToKICAgICAgICBSID0gcmFuZG9tLlJhbmRvbSgpCiAgICAgICAgaWYgdHlwZShoaW50KSA9PSBzdHI6CiAgICAgICAgICAgIG1kNSA9IGhhc2hsaWIubWQ1KGhpbnQuZW5jb2RlKCkpCiAgICAgICAgICAgIGhpbnRfbnVtYmVyID0gaW50KG1kNS5oZXhkaWdlc3QoKSwgMTYpCiAgICAgICAgUi5zZWVkKHNlY3JldF9udW1iZXIgKyBjbHVlX251bWJlciArIGhpbnRfbnVtYmVyKQogICAgICAgIHByaW50KGdjLnplcm9fcGFkKFIucmFuZGludCgxLCBnYy5DTFVFX1NQQUNFKSkpCgo="""))
# Please do the lab legitimately - if you need help, just ask us!