A cognitive-training application derived from the peer-reviewed study:
Ivan J, Nurdiansyah R, Parikesit AA. Mathematical Problem Solving: One Way to Prevent Dementia.
Iranian Journal of Medical Informatics. 2019; 8(1): e10.
https://doi.org/10.30699/IJMI.V8I1.179
Department of Bioinformatics, School of Life Sciences,
Indonesia International Institute for Life Sciences (i3L), Jakarta, Indonesia.
Dementia is a progressive syndrome affecting millions worldwide, with no effective cure. Previous studies show that cognitive activities — including mathematical problem solving — can slow cognitive decline. This application provides a simple, interactive arithmetic quiz to serve as a regular mental exercise, particularly for older adults.
Dementia-main/
├── math_quiz_engine.py # Core logic: NUMBER, EQUATION, MAIN procedures (pseudocode → Python)
├── Trial_2.py # Tkinter desktop GUI (updated to use engine)
├── app.py # Streamlit web frontend
├── requirements.txt # Python dependencies
├── LICENSE # GNU General Public License v3.0
└── README.md # This file
The program implements three procedures described in the original pseudocode:
| Procedure | Role |
|---|---|
| NUMBER | Randomly generates two operands and an operator (+, −, ×) within difficulty-specific ranges |
| EQUATION | Calculates the correct answer for the generated equation |
| MAIN | Manages a round of 5 questions, tracks right/wrong answers, measures calculation time |
| Level | Number Range |
|---|---|
| Easy | 0 – 10 |
| Medium | 11 – 20 |
| Hard | 21 – 30 |
Each round consists of exactly 5 questions. The user must answer correctly to advance; wrong answers keep the same question active. Calculation time is recorded at round end.
Python ≥ 3.10 required.
pip install streamlitTkinter ships with standard Python distributions (no extra install on most systems). If missing:
# Debian/Ubuntu
sudo apt install python3-tk
# macOS (Homebrew)
brew install python-tkstreamlit run app.pyOpens in your default browser at http://localhost:8501.
python Trial_2.pyfrom math_quiz_engine import QuizSession
session = QuizSession("easy")
while not session.finished:
print(session.equation_str)
answer = int(input("Your answer: "))
correct = session.submit_answer(answer)
print("Correct!" if correct else "Wrong, try again.")
print(f"Right: {session.right} Wrong: {session.wrong} Time: {session.elapsed}s")The UI mirrors the four-panel layout described in Ivan et al. (2019) Fig 2:
| Panel | Content |
|---|---|
| Upper-left | Introduction text + difficulty selection buttons |
| Upper-middle | Current equation, Right/Wrong score, START/RESET controls |
| Upper-right | Numpad (digits 0–9, minus, Del, Enter) + answer display |
| Bottom | Status messages — difficulty label, "Good Job!", calculation time |
If you use this code in your research or project, please cite:
Ivan J, Nurdiansyah R, Parikesit AA. Mathematical Problem Solving: One Way to Prevent
Dementia. Iran J Med Inform. 2019; 8(1): e10. https://doi.org/10.30699/IJMI.V8I1.179
This project is released under the GNU General Public License v3.0.
See LICENSE for full terms.
Copyright © 2019 Jeremias Ivan, Rizky Nurdiansyah, Arli A. Parikesit.
Streamlit port and engine refactor © 2026 Arli A. Parikesit, i3L University.
AI Assistance Disclaimer: This codebase was developed with the assistance of Claude Code. While the AI provided code generation, debugging, and structural support, the human developer maintains full responsibility for reviewing, testing, and maintaining all content and functionality.