New job: divison cipher
This commit is contained in:
parent
4d1399ec9b
commit
4c5e89aff7
42
jobs/division_cipher.py
Normal file
42
jobs/division_cipher.py
Normal file
@ -0,0 +1,42 @@
|
||||
import random
|
||||
from .base import Job
|
||||
|
||||
class DivisionCipherJob(Job):
|
||||
def get_name(self):
|
||||
return "TAJENKA (DELENI)"
|
||||
|
||||
def print_body(self, p):
|
||||
words = ["TONIK", "ROBOT", "MOBIL", "MAMISEK", "SLADKE", "BOBEK", "BOREC", "HUSTY", "VOLNO", "HOTOVE"]
|
||||
secret = random.choice(words)
|
||||
|
||||
p.text("Vylusti tajenku!\n")
|
||||
p.text("Vysledek deleni je poradi pismena\n")
|
||||
p.text("v abecede (A=1, B=2, C=3...).\n\n")
|
||||
|
||||
problems = []
|
||||
for char in secret:
|
||||
# A=1, B=2...
|
||||
target = ord(char) - ord('A') + 1
|
||||
|
||||
# Generate Dividend / Divisor = target
|
||||
# Ensure divisor is small enough for mental math
|
||||
divisor = random.randint(2, 9)
|
||||
dividend = target * divisor
|
||||
|
||||
problems.append((dividend, divisor))
|
||||
|
||||
# Print problems
|
||||
for i, (dividend, divisor) in enumerate(problems):
|
||||
p.text(f"{i+1}) {dividend} : {divisor} = ___\n")
|
||||
|
||||
p.text("\n")
|
||||
|
||||
# Print slots for solution
|
||||
p.text("Tajenka: " + " ".join(["___"] * len(secret)) + "\n\n")
|
||||
|
||||
# Print helper key
|
||||
p.text("Napoveda:\n")
|
||||
p.text("1=A 2=B 3=C 4=D 5=E 6=F 7=G 8=H\n")
|
||||
p.text("9=I 10=J 11=K 12=L 13=M 14=N 15=O\n")
|
||||
p.text("16=P 17=Q 18=R 19=S 20=T 21=U 22=V\n")
|
||||
p.text("23=W 24=X 25=Y 26=Z\n")
|
||||
@ -4,6 +4,7 @@ from jobs.math_homework import MathHomeworkJob
|
||||
from jobs.unit_conversion import UnitConversionJob
|
||||
from jobs.chess_puzzle import ChessPuzzleJob
|
||||
from jobs.maze import MazeJob
|
||||
from jobs.division_cipher import DivisionCipherJob
|
||||
|
||||
# ==========================================
|
||||
# CONFIGURATION
|
||||
@ -53,7 +54,8 @@ JOBS = [
|
||||
MathHomeworkJob(),
|
||||
UnitConversionJob(),
|
||||
ChessPuzzleJob(),
|
||||
MazeJob()
|
||||
MazeJob(),
|
||||
DivisionCipherJob()
|
||||
]
|
||||
|
||||
def run_tui():
|
||||
|
||||
Loading…
Reference in New Issue
Block a user