From c65028dd5d5d7e188898b550a0e4b147be126abb Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Thu, 30 Aug 2018 20:18:53 +0200 Subject: Initial --- complicated_wires.py | 30 ++++++++++++++++++++ morse.py | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ passwords.py | 58 +++++++++++++++++++++++++++++++++++++ wires.py | 49 ++++++++++++++++++++++++++++++++ 4 files changed, 217 insertions(+) create mode 100755 complicated_wires.py create mode 100755 morse.py create mode 100755 passwords.py create mode 100755 wires.py diff --git a/complicated_wires.py b/complicated_wires.py new file mode 100755 index 0000000..5821726 --- /dev/null +++ b/complicated_wires.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +import sys + +arr = [ + "cut", + "do not cut", + "cut", + "cut if two or more batteries", + "cut if last digit serial number even", + "cut if parallel port", + "do not cut", + "cut if parallel port", + "cut if last digit serial number even", + "cut if two or more batteries", + "cut", + "cut if two or more batteries", + "cut if last digit serial number even", + "cut if last digit serial number even", + "cut if parallel port", + "do not cut", +] + +n = 0 +arg = sys.argv[1] +if "r" in arg: n += 8 +if "b" in arg: n += 4 +if "s" in arg: n += 2 +if "l" in arg: n += 1 + +print(arr[n]) diff --git a/morse.py b/morse.py new file mode 100755 index 0000000..f99e2bd --- /dev/null +++ b/morse.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 +import sys + +morse = [ + ".-", + "-...", + "-.-.", + "-..", + ".", + "..-.", + "--.", + "....", + "..", + ".---", + "-.-", + ".-..", + "--", + "-.", + "---", + ".--.", + "--.-", + ".-.", + "...", + "-", + "..-", + "...-", + ".--", + "-..-", + "-.--", + "--..", +] + +mhz = [ + ["shell", "3.505"], + ["halls", "3.515"], + ["slick", "3.522"], + ["trick", "3.532"], + ["boxes", "3.535"], + ["leaks", "3.542"], + ["strobe", "3.545"], + ["bistro", "3.552"], + ["flick", "3.555"], + ["bombs", "3.565"], + ["break", "3.572"], + ["brick", "3.575"], + ["steak", "3.582"], + ["sting", "3.592"], + ["vector", "3.595"], + ["beats", "3.600"], +] + +def find(it, v): + for i, x in enumerate(it): + if x == v: + return i + + return -1 + + +word = [] + +for i, arg in enumerate(sys.argv[1:]): + if arg == "x" or arg == "X": + word.append(-1) + else: + v = find(morse, arg) + if v == -1: + print("Letter {} invalid".format(i+1)) + word.append(v) + +for i in range(5): + w = word[i:] + word[:i] + text = "".join(chr(c + ord('a')) for c in w) + + poss = [] + for [mt, m] in mhz: + if all([a == "`" or a == b for (a,b) in zip(text, mt)]): + poss.append(m) + + print(text + ": " + str(poss)) diff --git a/passwords.py b/passwords.py new file mode 100755 index 0000000..74f2ee4 --- /dev/null +++ b/passwords.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +import sys + +words = [ + "about", + "after", + "again", + "below", + "could", + "every", + "first", + "found", + "great", + "house", + "large", + "learn", + "never", + "other", + "place", + "plant", + "point", + "right", + "small", + "sound", + "spell", + "still", + "study", + "their", + "there", + "these", + "thing", + "think", + "three", + "water", + "where", + "which", + "world", + "would", + "write", +] + +index = 0 +poss = words + +for arg in sys.argv[1:]: + idcs = [] + if len(arg) == 0 or arg == "-": + index += 1 + continue + + for i in range(len(poss)): + if poss[i][index] in arg: + idcs.append(i) + + poss = [poss[i] for i in idcs] + index += 1 + +print(poss) diff --git a/wires.py b/wires.py new file mode 100755 index 0000000..cf754df --- /dev/null +++ b/wires.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +import sys + +def ask(s): + print("\x1B[1m" + s + "\x1B[0m: ", end="") + return int(input()) + +A = sys.argv[1] +if len(A) == 3: + if "r" not in A: + print("second") + elif A[-1] == "w": + print("last") + elif A.count("b") > 1: + print("last blue") + else: + print("last") + +elif len(A) == 4: + if A.count("r") > 1 and ask("last digit serial number") % 2 == 1: + print("last red") + elif A[-1] == "g" and "r" not in A: + print("first") + elif A.count("b") == 1: + print("first") + elif A.count("g") > 1: + print("last") + else: + print("second") + +elif len(A) == 5: + if A[-1] == "z" and ask("last digit serial number") % 2 == 1: + print("fourth") + elif A.count("r") == 1 and A.count("g") > 1: + print("first") + elif "z" not in A: + print("second") + else: + print("first") + +elif len(A) == 6: + if "g" not in A and ask("last digit serial number") % 2 == 1: + print("third") + elif A.count("g") == 1 and A.count("w") > 1: + print("fourth") + elif "r" not in A: + print("last") + else: + print("fourth") -- cgit v1.2.3