From e67023aad00b58de9d12fa32232f9492047f47e0 Mon Sep 17 00:00:00 2001 From: Lieuwe Rooijakkers Date: Tue, 4 Sep 2018 21:48:54 +0200 Subject: Add abc-wires script --- abc-wires.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 abc-wires.py 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 -- cgit v1.2.3-70-g09d2