diff options
| -rw-r--r-- | Makefile | 5 | ||||
| -rw-r--r-- | gen.py | 90 |
2 files changed, 95 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ae9fa6e --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +q0.py: + python gen.py > .107.unformatted.py + python .107.unformatted.py > .108.php + php .108.php > 0.py + rm .107.unformatted.py .108.php @@ -0,0 +1,90 @@ +from base64 import b64encode +from zlib import compress + +template0 = """ +from base64 import b64decode;exec(b64decode((b'~~').split(b'###')[0])) +""" +template1 = """ +from base64 import b64encode +from zlib import compress, decompress +j = b'107' +s = b"@@" +z = decompress(b64decode(s)).replace(b"j = b'%s'" % j, b"j = b'%03d'" % ((int(j)+1) % 108)) +t = z.replace(b"@"+b"@", b64encode(compress(z))) +u = b64encode(t) + +def fmt(u, f, php): + H = 10 + W = 17 + NL = b"\\n" + if php: + ss = b"<?echo zlib_decode(base64_decode(explode('###',''." + ls = b" '" + le = b"'." + NL + se = b"')[0]));" + else: + ss = b"from base64 import b64decode;exec(b64decode((b''+" + ls = b"b'" + le = b"'+" + NL + se = b"').split(b'###')[0]))" + o = ss + o += b"#" + u[0:9*W + 3 - len(ss)] + NL + i = 0 + u2 = u + b"###" + u + for y in range(9): + for dy in range(H if y%8 != 0 else H//2): + o += ls + for x in range(9*W): + if f[y][x//W] == "0": + o += b" " + else: + o += u2[i:i+1] + i += 1 + o += le + o += ls + o += u2[i:i+(9*W-len(se)+2)] + o += se + return o + +F1 = [ + "000000000", + "011111100", + "010000100", + "010000100", + "011111100", + "010000000", + "010000010", + "001111110", + "000000000", +] +F2 = [ + "000000000", + "001000000", + "001111100", + "010010000", + "000010000", + "011111110", + "000010000", + "000010000", + "000000000", +] + +v = fmt(u, F1, False) +if j == b"107": + print(fmt(b64encode(compress(v)), F2, True).decode("utf-8")) +else: + print(v.decode("utf-8")) +""" +template0 = template0.strip() + "\n" +template1 = template1.strip() + "\n" + +template0 = template0.encode("utf-8") +template1 = template1.encode("utf-8") + +template1_b64 = b64encode(compress(template1)) +replaced1 = template1.replace(b"@@", template1_b64) + +replaced1_b64 = b64encode(replaced1) +replaced0 = template0.replace(b"~~", replaced1_b64) + +print(replaced0.decode("utf-8"), end="") |
