Skip to content

Commit 0579e43

Browse files
committed
begin work on the Great Bomb Solver (tm)
0 parents  commit 0579e43

File tree

5 files changed

+171
-0
lines changed

5 files changed

+171
-0
lines changed

bomb.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Contains all the edgework stuff about the bomb.
2+
3+
4+
class Bomb:
5+
def __init__(self, serial_number: str, lit_indicators: list = None, unlit_indicators: list = None,
6+
batteries: int = 0, holders: int = 0, ports: list = None, module_count: int = 0, time: float = 0):
7+
if unlit_indicators is None:
8+
unlit_indicators = []
9+
if lit_indicators is None:
10+
lit_indicators = []
11+
if ports is None:
12+
ports = []
13+
14+
self.serial_number = serial_number
15+
self.lit_indicators = lit_indicators
16+
self.unlit_indicators = unlit_indicators
17+
self.holders = holders
18+
self.batteries = batteries
19+
self.ports = ports
20+
self.module_count = module_count
21+
self.time = time
22+
23+
self.aa_batteries = (batteries - holders) * 2
24+
self.d_batteries = batteries - self.aa_batteries

main.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from bomb import Bomb
2+
import modules
3+
4+
5+
# The driver file for this project.
6+
# Here, we execute all code to solve our bombs.
7+
8+
# -------------------#
9+
# EDGEWORK #
10+
# -------------------#
11+
12+
current_bomb = Bomb(
13+
"ABCDEF", # serial number
14+
lit_indicators=["NSA"],
15+
unlit_indicators=[],
16+
batteries=2,
17+
holders=1,
18+
19+
ports=[
20+
[],
21+
["RJ", "RCA"]
22+
],
23+
24+
module_count=15,
25+
time=20
26+
)
27+
28+
29+
# -------------------#
30+
# SOLVING MODULES #
31+
# -------------------#
32+
modules.button.solve_button(current_bomb, "why", "red")

modules/button/__init__.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from bomb import Bomb
2+
from termcolor import cprint
3+
4+
5+
def solve_button(bomb: Bomb, word: str, color: str):
6+
# Preprocessing
7+
word = word.upper()
8+
color = color.upper()
9+
10+
# True is press and hold
11+
# False is press and release
12+
result = None
13+
if word == "ABORT" and color == "BLUE":
14+
result = True
15+
elif bomb.batteries > 1 and word == "DETONATE":
16+
result = False
17+
elif color == "WHITE" and "CAR" in bomb.lit_indicators:
18+
result = True
19+
elif bomb.batteries > 2 and "FRK" in bomb.lit_indicators:
20+
result = False
21+
elif color == "YELLOW":
22+
result = True
23+
elif color == "RED" and word == "HOLD":
24+
result = False
25+
else:
26+
result = True
27+
28+
if result:
29+
print("Press and hold the button. Then observe the strip color.")
30+
cprint("Blue: 4", 'blue')
31+
cprint("Yellow: 5", 'yellow')
32+
print("Anything else: 1")
33+
else:
34+
print("Press and IMMEDIATELY release.")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from bomb import Bomb
2+
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# All the adjacent letters in KTANE.
2+
arrays = {
3+
"A": ["GJMOY", "HKPRW"],
4+
"B": ["IKLRT", "CDFYZ"],
5+
"C": ["BHIJW", "DEMTU"],
6+
"D": ["IKOPQ", "CJTUW"],
7+
"E": ["ACGIJ", "KSUWZ"],
8+
"F": ["CERVY", "AGJPQ"],
9+
"G": ["ACFNS", "HOQYZ"],
10+
"H": ["LRTUX", "DKMPS"],
11+
"I": ["DLOWZ", "EFNUV"],
12+
"J": ["BQTUW", "EHIOS"],
13+
"K": ["AFPXY", "DIORZ"],
14+
"L": ["GKPTZ", "ABRVX"],
15+
"M": ["EILQT", "BFPWX"],
16+
"N": ["PQRSV", "AFGHL"],
17+
"O": ["HJLUZ", "IQSTX"],
18+
"P": ["DMNOX", "CFHKR"],
19+
"Q": ["CEOPV", "BDIKN"],
20+
"R": ["AEGSU", "BNOXY"],
21+
"S": ["ABEKQ", "GMVYZ"],
22+
"T": ["GVXYZ", "CJLSU"],
23+
"U": ["FMVXZ", "BILNY"],
24+
"V": ["DHMNW", "AEJQX"],
25+
"W": ["DFHMN", "GLQRT"],
26+
"X": ["BDFKW", "AJNOV"],
27+
"Y": ["BCHSU", "EGMTW"],
28+
"Z": ["JNRSY", "CLMPV"],
29+
}
30+
31+
32+
def calc_letters(letterlist):
33+
if None in letterlist:
34+
print("Invalid arguments. Please try again.")
35+
return
36+
37+
for i in range(3):
38+
for j in range(4):
39+
cur_lists = arrays[letterlist[i][j]]
40+
works = False
41+
42+
for letter in cur_lists[0]:
43+
if (j > 0 and letterlist[i][j - 1] == letter) or (j < 3 and letterlist[i][j + 1] == letter):
44+
works = True
45+
break
46+
47+
for letter in cur_lists[1]:
48+
if (i > 0 and letterlist[i - 1][j] == letter) or (i < 2 and letterlist[i + 1][j] == letter):
49+
works = True
50+
break
51+
52+
print(letterlist[i][j] if works else ".", end="")
53+
print()
54+
55+
56+
def get_input_row():
57+
row = input()
58+
59+
if len(row) != 4:
60+
print("Invalid argument. Please enter that again.")
61+
return get_input_row()
62+
63+
return list(row.upper())
64+
65+
66+
print("Input your buttons in this format:")
67+
print("""ABCD
68+
EFGH
69+
IJKL
70+
""")
71+
72+
letters = [get_input_row(), get_input_row(), get_input_row()]
73+
74+
print("Your input:")
75+
print(letters)
76+
print()
77+
print('Buttons to press:')
78+
79+
calc_letters(letters)

0 commit comments

Comments
 (0)