This repository has been archived by the owner on Jul 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ktane.py
429 lines (404 loc) · 15.8 KB
/
ktane.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
print("KTaNE-cmdexp")
print("***********")
print("RED\tr")
print("BLUE\tb")
print("WHITE\tw")
print("YELLOW\ty")
print("BLACK\tB")
print("GREEN\tg")
cmaps = {"r": "red", "b": "blue", "w": "white", "y": "yellow", "B": "black", "g": "green"}
try:
exec(open("data.txt", "r").read())
lastSerialOdd = True if int(last) % 2 == 1 else False
vowelSerial = bool(vowels)
batteries = int(bats)
indics = []
if bool(car): indics.append("CAR")
if bool(frk): indics.append("FRK")
pp = bool(parallel)
except:
print("\n>>> WARNING: data.txt NOT FORMATTED CORRECT!")
print("\n")
def wires():
w = input("[wires] wires >> ").replace(" ", "")
if len(w) == 3:
if "r" not in w: print("<< cut SECOND wire")
elif w[-1] == "w": print("<< cut LAST wire")
elif w.count("b") > 1: print("<< cut LAST BLUE wire")
else: print("<< cut LAST wire")
elif len(w) == 4:
if w.count("r") > 1 and lastSerialOdd: print("<< cut LAST RED wire")
elif w[-1] == "y" and "r" not in w: print("<< cut FIRST wire")
elif w.count("b") == 1: print("<< cut FIRST wire")
elif w.count("y") > 1: print("<< cut LAST wire")
else: print("<< cut SECOND wire")
elif len(w) == 5:
if w[-1] == "B" and lastSerialOdd: print("<< cut FOURTH wire")
elif w.count("r") == 1 and w.count("y") > 1: print("<< cut FIRST wire")
elif "B" not in w: print("<< cut SECOND wire")
else: print("<< cut FIRST wire")
else:
if "y" not in w and lastSerialOdd: print("<< cut THIRD wire")
elif w.count("y") == 1 and w.count("w") > 1: print("<< cut FOURTH wire")
elif "r" not in w: print("<< cut LAST wire")
else: print("<< cut FOURTH wire")
def rHeldButton():
print("<< HOLD button")
col = input("[button] [held] colour > ")
if col == "b": print("< release when 4 in any position")
elif col == "w": print("< release when 1 in any position")
elif col == "y": print("< release when 5 in any position")
else: print("< release when 1 in any position")
def button():
bcol = input("[button] colour >> ").strip()[0]
txt = input("[button] text >> ").lower().strip()[0]
if bcol == "b" and txt == "a": rHeldButton()
elif batteries > 1 and txt == "d": print("<< CLICK button")
elif bcol == "w" and "CAR" in indics: rHeldButton()
elif batteries > 2 and "FRK" in indics: print("<< CLICK button")
elif bcol == "y": rHeldButton()
elif bcol == "r" and txt == "h": print("<< CLICK button")
else: rHeldButton()
keys = [
["balloon", "pyramid", "lambda", "lightning", "spaceship", "h", "backc"],
["e", "balloon", "backc", "curly", "wstar", "h", "question"],
["copyright", "butt", "curly", "inkblot", "halfr", "lambda", "wstar"],
["six", "paragraph", "p", "spaceship", "inkblot", "question", "smiley"],
["trident", "smiley", "p", "c", "paragraph", "snake", "bstar"],
["six", "e", "hash", "ae", "trident", "n", "omega"]
]
def keypad():
symbs = input("[keypad] symbols >> ").strip().split(" ")
found = False
print("<< ", end="")
for k in keys:
if all([y in k for y in symbs]):
found = True
for word in k:
if word in symbs:
print(word, end=" ")
print()
if not found:
print("?????")
fullSimon = {
True: {
0: {"r": "b", "b": "r", "g": "y", "y": "g"},
1: {"r": "y", "b": "g", "g": "b", "y": "r"},
2: {"r": "g", "b": "r", "g": "y", "y": "b"}
},
False: {
0: {"r": "b", "b": "y", "g": "g", "y": "r"},
1: {"r": "r", "b": "b", "g": "y", "y": "g"},
2: {"r": "y", "b": "g", "g": "b", "y": "r"}
}
}
def simon():
strikes = int(input("[simon] strikes? >> ").strip()[0])
while True:
flashes = input("[simon] flashes /q >> ").strip()
if flashes == "q": return
print("<< ", end="")
for flash in flashes:
converted = fullSimon[vowelSerial][strikes][flash]
print(cmaps[converted], end=" ")
print()
fullWho = {
'ready': ['yes', 'okay', 'what', 'middle', 'left', 'press', 'right', 'blank', 'ready', 'no', 'first', 'uhhh', 'nothing', 'wait'],
'first': ['left', 'okay', 'yes', 'middle', 'no', 'right', 'nothing', 'uhhh', 'wait', 'ready', 'blank', 'what', 'press', 'first'],
'no': ['blank', 'uhhh', 'wait', 'first', 'what', 'ready', 'right', 'yes', 'nothing', 'left', 'press', 'okay', 'no', 'middle'],
'blank': ['wait', 'right', 'okay', 'middle', 'blank', 'press', 'ready', 'nothing', 'no', 'what', 'left', 'uhhh', 'yes', 'first'],
'nothing': ['uhhh', 'right', 'okay', 'middle', 'yes', 'blank', 'no', 'press', 'left', 'what', 'wait', 'first', 'nothing', 'ready'],
'yes': ['okay', 'right', 'uhhh', 'middle', 'first', 'what', 'press', 'ready', 'nothing', 'yes', 'left', 'blank', 'no', 'wait'],
'what': ['uhhh', 'what', 'left', 'nothing', 'ready', 'blank', 'middle', 'no', 'okay', 'first', 'wait', 'yes', 'press', 'right'],
'uhhh': ['ready', 'nothing', 'left', 'what', 'okay', 'yes', 'right', 'no', 'press', 'blank', 'uhhh', 'middle', 'wait', 'first'],
'left': ['right', 'left', 'first', 'no', 'middle', 'yes', 'blank', 'what', 'uhhh', 'wait', 'press', 'ready', 'okay', 'nothing'],
'right': ['yes', 'nothing', 'ready', 'press', 'no', 'wait', 'what', 'right', 'middle', 'left', 'uhhh', 'blank', 'okay', 'first'],
'middle': ['blank', 'ready', 'okay', 'what', 'nothing', 'press', 'no', 'wait', 'left', 'middle', 'right', 'first', 'uhhh', 'yes'],
'okay': ['middle', 'no', 'first', 'yes', 'uhhh', 'nothing', 'wait', 'okay', 'left', 'ready', 'blank', 'press', 'what', 'right'],
'wait': ['uhhh', 'no', 'blank', 'okay', 'yes', 'left', 'first', 'press', 'what', 'wait', 'nothing', 'ready', 'right', 'middle'],
'press': ['right', 'middle', 'yes', 'ready', 'press', 'okay', 'nothing', 'uhhh', 'blank', 'left', 'first', 'what', 'no', 'wait'],
'you': ['sure', 'you', 'are', 'your', "you're", 'next', 'uh', 'huh', 'ur', 'hold', 'what?', 'you', 'uh', 'uh', 'like', 'done', 'u'],
'you are': ['your', 'next', 'like', 'uh', 'huh', 'what?', 'done', 'uh', 'uh', 'hold', 'you', 'u', "you're", 'sure', 'ur', 'you', 'are'],
'your': ['uh', 'uh', 'you', 'are', 'uh', 'huh', 'your', 'next', 'ur', 'sure', 'u', "you're", 'you', 'what?', 'hold', 'like', 'done'],
"you're": ['you', "you're", 'ur', 'next', 'uh', 'uh', 'you', 'are', 'u', 'your', 'what?', 'uh', 'huh', 'sure', 'done', 'like', 'hold'],
'ur': ['done', 'u', 'ur', 'uh', 'huh', 'what?', 'sure', 'your', 'hold', "you're", 'like', 'next', 'uh', 'uh', 'you', 'are', 'you'],
'u': ['uh', 'huh', 'sure', 'next', 'what?', "you're", 'ur', 'uh', 'uh', 'done', 'u', 'you', 'like', 'hold', 'you', 'are', 'your'],
'uh huh': ['uh', 'huh', 'your', 'you', 'are', 'you', 'done', 'hold', 'uh', 'uh', 'next', 'sure', 'like', "you're", 'ur', 'u', 'what?'],
'uh uh': ['ur', 'u', 'you', 'are', "you're", 'next', 'uh', 'uh', 'done', 'you', 'uh', 'huh', 'like', 'your', 'sure', 'hold', 'what?'],
'what?': ['you', 'hold', "you're", 'your', 'u', 'done', 'uh', 'uh', 'like', 'you', 'are', 'uh', 'huh', 'ur', 'next', 'what?', 'sure'],
'done': ['sure', 'uh', 'huh', 'next', 'what?', 'your', 'ur', "you're", 'hold', 'like', 'you', 'u', 'you', 'are', 'uh', 'uh', 'done'],
'next': ['what?', 'uh', 'huh', 'uh', 'uh', 'your', 'hold', 'sure', 'next', 'like', 'done', 'you', 'are', 'ur', "you're", 'u', 'you'],
'hold': ['you', 'are', 'u', 'done', 'uh', 'uh', 'you', 'ur', 'sure', 'what?', "you're", 'next', 'hold', 'uh', 'huh', 'your', 'like'],
'sure': ['you', 'are', 'done', 'like', "you're", 'you', 'hold', 'uh', 'huh', 'ur', 'sure', 'u', 'what?', 'next', 'your', 'uh', 'uh'],
'like': ["you're", 'next', 'u', 'ur', 'hold', 'done', 'uh', 'uh', 'what?', 'uh', 'huh', 'you', 'like', 'sure', 'you', 'are', 'your']
}
def whoS2(msgd):
match = input(f"[whoson] [step 2] {msgd} > ")
print("<< ", end="")
[print(t, end=" ") for t in fullWho[match]]
print()
def whoson():
msg = ""
display = input("[whoson] display (or `empty`) >> ").strip().lower()
if display in ("first", "okay", "ur", "c"):
msg += "top "
elif display in ("yes", "nothing", "blank", "led", "read", "red", "you", "your", "you're", "their", "they are"):
msg += "middle "
else:
msg += "bottom "
if display in ("yes", "nothing", "empty", "led", "reed", "leed", "they're", "they are"):
msg += "left"
else:
msg += "right"
whoS2(msg)
def query(): return int(input("[memory] display >> ").strip()[0]), input("[memory] nums >> ").strip()
def memory():
history = [] # (position, label)
d, n = query()
if d == 1 or d == 2:
print(f"<< press {n[1]}")
history.append((1, n[1]))
elif d == 3:
print(f"<< press {n[2]}")
history.append((2, n[2]))
else:
print(f"<< press {n[3]}")
history.append((3, n[3]))
d, n = query()
if d == 1:
print("<< press 4")
history.append((n.index("4"), 4))
elif d == 2 or d == 4:
print(f"<< press {n[history[0][0]]}")
history.append((history[0][0], n[history[0][0]]))
else:
print(f"<< press {n[0]}")
history.append((0, n[0]))
d, n = query()
if d == 1:
print(f"<< press {history[1][1]}")
history.append((n.index(history[1][1]), history[1][1]))
elif d == 2:
print(f"<< press {history[0][1]}")
history.append((n.index(history[0][1]), history[0][1]))
elif d == 3:
print(f"<< press {n[2]}")
history.append((2, n[2]))
else:
print("<< press 4")
history.append((n.index("4"), 4))
d, n = query()
if d == 1:
print(f"<< press {n[history[0][0]]}")
history.append((history[0][0], n[history[0][0]]))
elif d == 2:
print(f"<< press {n[0]}")
history.append((0, n[0]))
else:
print(f"<< press {n[history[1][0]]}")
history.append((history[1][0], n[history[1][0]]))
d, n = query()
if d == 1:
print(f"<< press {history[0][1]}")
history.append((n.index(history[0][1]), history[0][1]))
elif d == 2:
print(f"<< press {history[1][1]}")
history.append((n.index(history[1][1]), history[1][1]))
elif d == 3:
print(f"<< press {history[3][1]}")
history.append((n.index(history[3][1]), history[3][1]))
else:
print(f"<< press {history[2][1]}")
history.append((n.index(history[2][1]), history[2][1]))
morseCode = {
".-": "a",
"-...": "b",
"-.-.": "c",
"-..": "d",
".": "e",
"..-.": "f",
"--.": "g",
"....": "h",
"..": "i",
".---": "j",
"-.-": "k",
".-..": "l",
"--": "m",
"-.": "n",
"---": "o",
".--.": "p",
"--.-": "q",
".-.": "r",
"...": "s",
"-": "t",
"..-": "u",
"...-": "v",
".--": "w",
"-..-": "x",
"-.--": "y",
"--..": "z"
}
freqs = {
"she": "505", # shell
"hal": "515", # halls
"sli": "522", # slick
"tri": "532", # trick
"box": "535", # boxes
"lea": "542", # leaks
"str": "545", # strobe
"bis": "552", # bistro
"fli": "555", # flick
"bom": "565", # bombs
"bre": "572", # break
"bri": "575", # brick
"ste": "582", # steak
"sti": "592", # sting
"vec": "595", # vector
"bea": "600" # beats
}
def morse():
message = input("[morse] first three >> ").strip().split(" ")
word = ""
for char in message[:3]:
if char in morseCode:
word += morseCode[char]
else:
word.append("X")
if word in freqs:
print(f"<< {word} - 3.{freqs[word]} MHz")
else:
print(f"<< {word} - ?????")
def compli():
wall = input("[compli] rbsl? >> ").lower().strip().split(" ")
madec = False
for indx in range(len(wall)):
v = "".join(sorted(wall[indx]))
if v in ("l", "bs", "blrs"):
continue # Never cut these wires
elif v in ("r", "b", "br", "blr"):
if not lastSerialOdd:
print(f"<< cut wire {indx+1}")
madec = True
elif v in ("bl", "brs", "bls"):
if pp:
print(f"<< cut wire {indx+1}")
madec = True
elif v in ("lr", "lrs", "ls"):
if batteries >= 2:
print(f"<< cut wire {indx+1}")
madec = True
else:
print(f"<< cut wire {indx+1}")
madec = True
if not madec:
print("<< DO NOT cut any wires")
wseqs = {
"r": ["c", "b", "a", "ac", "b", "ac", "abc", "ab", "b"],
"b": ["b", "ac", "b", "a", "b", "bc", "c", "ac", "a"],
"B": ["abc", "ac", "b", "ac", "b", "bc", "ab", "c", "c"]
}
def seqwir():
occurs = {"r": 0, "b": 0, "B": 0}
for zz in range(4):
_ = zz
wires = input("[seqwir] wires >> ").strip().split(" ")
if wires == ["q"]: return
madecut = False
for ind in range(len(wires)):
col = wires[ind][0]
goto = wires[ind][1].lower()
cutif = wseqs[col][occurs[col]]
if goto in cutif:
madecut = True
if ind == 0: print("<< cut FIRST wire")
elif ind == 1: print("<< cut SECOND wire")
else: print("<< cut THIRD wire")
occurs[col] += 1
if not madecut:
print("<< DO NOT cut any wires")
maz = {
(1, 2): 1,
(3, 6): 1,
(2, 4): 2,
(5, 2): 2,
(4, 4): 3,
(6, 4): 3,
(1, 1): 4,
(1, 4): 4,
(4, 6): 5,
(5, 3): 5,
(3, 5): 6,
(5, 1): 6,
(2, 1): 7,
(2, 6): 7,
(4, 1): 8,
(3, 4): 8,
(1, 5): 9,
(3, 2): 9
}
def mazes():
coord = input("[mazes (beta)] marker >> ").strip().split(" ")
gpair = tuple(map(int, coord))
print(f"<< Use maze {maz[gpair]}")
possibles = [
"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"
]
def pwords():
choices = []
for i in range(3):
choices.append(input(f"[pwords] column {i+1} >> ").strip().lower())
found = False
print("<< ", end="")
for pw in possibles:
totalsame = 0
for index in range(3):
if pw[index] in choices[index]:
totalsame += 1
if totalsame == 3:
found = True
print(pw.upper(), end=" ")
if not found:
print("?????")
else:
print()
hscreen = """
wires:\t\tWires (simple)
button:\t\tThe Button
keypad:\t\tKeypads (symbols)
simon:\t\tSimon Says
whoson:\t\tWho's on First
memory:\t\tMemory
morse:\t\tMorse Code
compli:\t\tComplicated Wires
seqwir:\t\tWire Sequences
mazes:\t\tMazes
pwords:\t\tPasswords
Note: typing first two letters will also work."""
# handler
while True:
print()
mainin = input(">>> ").strip().lower()
if mainin in ("h", "help"):
print(hscreen)
continue
elif mainin in ("q", "quit", "exit"):
exit()
mainin = mainin.replace(" ", "")[:2]
if mainin == "wi": wires()
elif mainin == "bu": button()
elif mainin == "ke": keypad()
elif mainin == "si": simon()
elif mainin == "wh": whoson()
elif mainin == "me": memory()
elif mainin == "mo": morse()
elif mainin == "co": compli()
elif mainin == "se": seqwir()
elif mainin == "ma": mazes()
elif mainin == "pw": pwords()
else: continue