aboutsummaryrefslogtreecommitdiffhomepage
path: root/gen.py
blob: e88c27d9fc8a13ef2e7554bbbccefdd4b01d197b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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="")