diff options
author | Lieuwe Rooijakkers <lieuwerooijakkers@gmail.com> | 2018-09-04 21:48:54 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2018-09-04 21:48:54 +0200 |
commit | e67023aad00b58de9d12fa32232f9492047f47e0 (patch) | |
tree | 23bb802d051018542cf70b44d44b337a69eef22d | |
parent | c65028dd5d5d7e188898b550a0e4b147be126abb (diff) |
-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 |