6 pallets
= {'p': 'Prittles', 'n': 'Nuzzles', 'c': 'Crottles',
7 's': 'Skipples', 'd': 'Dupples'}
10 match
= re
.match('\(= t(?P<t>\d+)(?P<p>.) (?P<v>\d+)\)', line
)
12 trucks
[match
.group('t')] = trucks
.get(match
.group('t'), {})
13 trucks
[match
.group('t')][pallets
[match
.group('p')]] = \
16 print('$\\begin{array}{|l|lllll|}')
18 print('\t\\text{{Truck}} & {}\\\\'.format(
19 ' & '.join('\\text{{{}}}'.format(p
) for p
in sorted(pallets
.values()))))
21 for truck
in sorted(trucks
):
22 print('\t{} & {}\\\\'.format(truck
, ' & '.join(
23 str(p
[1]) for p
in sorted(trucks
[truck
].items()))))
25 print('\t\\text{{Total}} & {}\\\\'.format(' & '.join(
26 str(sum(t
[p
] for t
in trucks
.values())) for p
in
27 sorted(pallets
.values()))))
28 print('\t\\bottomrule')
29 print('\\end{array}$')