New job: divison cipher
This commit is contained in:
@@ -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")
|
||||
Reference in New Issue
Block a user