aboutsummaryrefslogtreecommitdiff
path: root/flipper.py
blob: 27dcd7002a928b52dabddc2e0e12810ec9812673 (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
#!/usr/bin/python

from sys import argv

mem = [{}, {}]

def flip(x, y):
    if y not in mem[x]:
        mem[x][y] = 1
    else:
        mem[x][y] = 1 - mem[x][y]
    return mem[x][y]

with open(argv[1]) as f:
    lines = f.readlines()

while True:
    for line in lines:
        l = list(map(int, line.split()))
        x = l[0]
        for i in range(1, len(l)):
            x = flip(x, l[i])
        print(x)
    if 0 not in mem[0] or mem[0][0] == 0:
        exit()