Update math

This commit is contained in:
Dmitry Bikulov
2025-09-16 00:28:52 +03:00
parent 93883a4470
commit 45e0da6ada
3 changed files with 6 additions and 9 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
*.pyc
static/.DS_Store
*.zip
.DS_Store

View File

@@ -78,17 +78,13 @@ class Session:
@staticmethod
def _generate_questions(n: int) -> List[Dict]:
# Build unique unordered pairs (avoid mirrored duplicates like 6×8 and 8×6)
all_pairs = [(a, b) for a in range(2, 6) for b in range(a, 6)] # a <= b
all_pairs = [(a, b) for a in range(2, 10) for b in range(2, 10)] # a <= b
count = min(n, len(all_pairs))
print(count)
picked = random.sample(all_pairs, count)
questions: List[Dict] = []
for a0, b0 in picked:
# Randomize order for variety while keeping uniqueness by unordered pair
if random.random() < 0.5:
a, b = a0, b0
else:
a, b = b0, a0
for a, b in picked:
correct = a * b
options = Session._generate_options(a, b, correct)
questions.append({

View File

@@ -71,7 +71,7 @@ body {
.result { margin-top: 18px; padding: 18px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.result .score { font-size: 20px; margin-bottom: 8px; }
.again { padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: #0f172a; cursor: pointer; box-shadow: var(--shadow); }
.again { margin-top: 1em; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: #0f172a; cursor: pointer; box-shadow: var(--shadow); }
.again:hover { background: #f1f5f9; }
.hidden { display: none; }