6a609e797c8fbdb3533ccde823c860801f866c8d
8 match
= re
.match('\(= c(?P<c>\d+)(?P<t>.) (?P<v>\d+)\)', line
)
10 c
= int(match
.group('c'))
11 comps
[c
] = comps
.get(c
, {})
12 comps
[c
][match
.group('t')] = int(match
.group('v'))
14 maxx
= max(c
['x']+c
['w'] for c
in comps
.values())
15 maxy
= max(c
['y']+c
['h'] for c
in comps
.values())
16 print('$\\begin{{array}}{{|l|{}|}}'.format('@{}c@{}'*maxx
))
18 print('\t & {}\\\\'.format(
19 ' & '.join(map(str, range(1, maxx
+1)))))
21 for y
in range(1, maxy
+1):
22 print('\t{} & '.format(y
), end
='')
23 for x
in range(1, maxx
+1):
24 cs
= [c
for c
in comps
if
25 comps
[c
]['y'] + comps
[c
]['h'] >= y
and comps
[c
]['y'] <= y
and
26 comps
[c
]['x'] + comps
[c
]['w'] >= x
and comps
[c
]['x'] <= x
]
28 print('\\hspace{{.5mm}}{}\\hspace{{.5mm}}'.format(
29 '\mathbf{{{}}}'.format(cs
[0]) if cs
[0] <= 3 else cs
[0]), end
='')
34 print('\t\\bottomrule')
35 print('\\end{array}$')