summaryrefslogtreecommitdiff
path: root/abc-wires.py
blob: 2296c24052bb686b5363f9c1dd1a54771de73f88 (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
26
27
28
29
30
31
32
33
#!/usr/bin/env python3

counts = {
    'red': 0,
    'blue': 0,
    'black': 0,
}

sequences = {
    'red': [ 'c', 'b', 'a', 'ac', 'b', 'ac', 'abc', 'ab', 'b' ],
    'blue': [ 'b', 'ac', 'b', 'a', 'b', 'bc', 'c', 'ac', 'a' ],
    'black': [ 'abc', 'ac', 'b', 'ac', 'b', 'bc', 'ab', 'c', 'c' ],
}

last = None
while True:
    s = input()

    if s == 'u' and last is not None:
        counts[last] -= 1
    else:
        color = {
            'r': 'red',
            'b': 'blue',
            'z': 'black',
        }.get(s[0])

        count = counts[color]
        sequence = sequences[color]
        print("cut" if s[1] in sequence[count] else "DON'T cut")

        counts[color] += 1
        last = color