A dashboard that tells the truth
The request#
A dashboard to log lottery draws by date (TOTO: 6 numbers from 1–49 plus an additional; 4D: 23 four-digit numbers per draw), store everything in one Excel file, and suggest "high probability" numbers.
The honest part first#
No method predicts a fair lottery
Every draw is independent and random: each number has exactly the same chance every time, whatever happened before. "Hot" numbers (drawn often) and "due" numbers (not drawn for a while) are patterns we see, not patterns that cause anything. This is the gambler's fallacy.
So instead of pretending, the dashboard measures. It includes a backtest: before each saved draw, it asks each strategy to pick numbers using only the earlier draws, then counts how many matched. It compares that with what random picks would average:
- TOTO, 7 picks from 49 with 6 drawn: random gets 7 × 6 ÷ 49 ≈ 0.86 matches per draw.
- If "Hot" averages about 0.86 too, the data itself shows it's no better than random.
Why build a feature that disproves the feature?
Because the user's real goal is to make good decisions. A tool that flatters is worse than useless. Let the evidence speak, and let the person decide.
Architecture: why a tiny server?#
A web page in a browser can't write to an Excel file on your phone. So:
index.html (dashboard in the browser)
│ fetch("api/draws", ...)
▼
server.py (Python, runs on the phone, port 8765)
│ openpyxl
▼
Millionaire.xlsx ── sheet "ToTo" and sheet "4D"
- openpyxl reads and writes Excel files without Excel installed.
- One workbook, one sheet per game; a shared helper adds sheets safely.
- 4D numbers are stored as text, otherwise Excel turns
0427into427.
0042 vs 042
A typed "042" was silently padded to "0042". Helpful when reading old Excel cells, wrong when typing new ones. Fix: strict 4-digit validation for input, lenient cleaning only for reading. Lesson: be strict about what you accept, forgiving about what you read.
Validation: the boring hero#
Before saving a TOTO draw: exactly 6 main numbers, all 1–49, no repeats, an additional number not among them, and no second draw for the same date unless "Replace" is ticked. Each failure has a plain message ("Main numbers must all be different.").
Testing on a copy#
Every test ran against a copy of the Excel file in a scratch folder, so real data was never touched by experiments.
Key takeaways#
- When a request rests on a false premise, say so kindly, then build something genuinely useful.
- Backtesting against a random baseline is how you check any "strategy".
- Browsers can't write local files; a small local server can.
- Validate input strictly, test on copies.
Quick quiz#
1. A number hasn't come up in 20 draws. Is it more likely next time?
No. Each draw is independent; its chance is the same as every other number's.
2. Why store 4D numbers as text?
So leading zeros survive: Excel would turn 0427 into 427.
Try it yourself#
Beat random (or not)
Add 30+ real draws, then read the Backtest table. Does any strategy's "Avg hits" consistently beat the "Random gets" column?