summaryrefslogtreecommitdiffstats
path: root/6/inputconv.py
blob: fa2873dd55d757b92dd349a97cd1418f5d351185 (plain)
1
2
3
4
from struct import pack
with open('inputbin', 'wb') as f:
    for action, start, end in (({'turn on': 1, 'turn off': -1, 'toggle': 2}[action], tuple(map(int, begin.split(','))), tuple(map(int, end.split(',')))) for action, begin, end in ((*l.rsplit(' ', maxsplit=1), r) for l, r in (l.rstrip('\n').split(' through ') for l in open('input')))):
        f.write(pack('>bHHHH', action, *start, *end))