diff options
-rwxr-xr-x | abc-wires.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/abc-wires.py b/abc-wires.py new file mode 100755 index 0000000..2296c24 --- /dev/null +++ b/abc-wires.py @@ -0,0 +1,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 |