about summary refs log tree commit diff
path: root/12/TP-ThanhHoá-2009/bai4pas_srcgen.py
blob: e345caa4cad5520f1d1965891a21d63b9d0d5d7b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python3

from bai4 import libai4


with open("BAI4.PAS", "w") as f:
    f.write("const\n  m: array[1..9] of byte = (")
    l = [libai4(i) for i in range(1, 10)]
    f.write(", ".join([str(len(i)) for i in l]))
    f.write(");\n  equa: array[1..9] of ansistring = (\n");
    l0 = []
    for i in l:
        s = "    #10" + "".join(["'" + j.replace("\n", "'#10") for j in i])
        l0.append(s)
    f.write(",\n".join(l0))
    f.write("\n  );\n\nvar\n  n: byte;\n  f: text;\n\nbegin\n")
    f.write("  assign(f, 'BAI4.INP');\n  reset(f);\n  read(f, n);\n")
    f.write("  close(f);\n\n  assign(f, 'BAI4.OUT');\n  rewrite(f);\n")
    f.write("  write(f, m[n], equa[n]);\n  close(f)\nend.\n")