π Winner β Best Chemistry Project, School Science Fair
Built independently by a Grade 9 student of HURDCO International School, as an exploration of computational chemistry and interactive education.
An app made by 16-year-old Afra Nawar for struggling students to enjoy relearning chemistry through
the interface of a simple game.
Bond Balancer is a fully interactive desktop chemistry learning application built in Python. It combines real mathematical equation-balancing (using rational nullspace computation) with a gamified quiz system and an interactive virtual laboratory; making chemistry accessible, visual, and competitive for students at any level.
- 30-question pool with 10 randomly selected questions per session
- 20-second countdown timer per question with a colour-changing progress bar (green β yellow β orange β red)
- Bonus +2 points awarded for answering within the first 15 seconds
- "Reveal Answer" option that gracefully removes the question from scoring
- Real-time score tracking with audio feedback for correct, incorrect, bonus, and timeout events
- Player name entry with results saved to a persistent leaderboard
- Balances 20 chemical equations using a rational nullspace algorithm (the same mathematical method used in professional chemistry software)
- Shows full working: element matrix construction, solution vector, and final balanced equation
- Alternating colour-coded steps for readability
- Audio and visual feedback on selection and solution
- Select two reactants from 6 gas/element species (Hβ, Oβ, Clβ, K, Nβ, CHβ)
- Set molar amounts using interactive sliders (0.5β5 mol)
- Predicts reaction type (ionic, covalent, combustion) using element classification logic
- Animated label flashing on reaction run
- Scrollable output log with stoichiometric ratio display
- All quiz scores saved to
leaderboard.jsonwith timestamps - Top 10 displayed on the main menu at all times
- Full leaderboard accessible in a separate window
- Sorted by score descending, timestamp as tiebreaker
Most equation balancers use trial and error. However, Bond Balancer is unique, because it uses linear algebra and stoichiometric prediction logic.
Each chemical equation is converted into an element matrix where:
- Rows represent elements involved
- Columns represent chemical species (reactants as positive, products as negative)
The nullspace of this matrix gives the coefficients that balance the equation. The algorithm uses Gaussian elimination over rational numbers (via Python's
fractions.Fraction) to find the smallest integer solution vector β guaranteeing exact, reduced coefficients with no floating-point errors.
Example: Hβ + Oβ β HβO
Element matrix:
H: 2 0 -2
O: 0 2 -1
Nullspace β [2, 1, 2]
Balanced: 2Hβ + Oβ β 2HβO β
| Component | Technology |
|---|---|
| Language | Python 3.x |
| GUI Framework | Tkinter + TTK |
| Mathematical Core | fractions.Fraction, math.gcd |
| Audio | winsound (Windows), threaded beep sequences |
| Persistence | JSON (leaderboard.json) |
| Concurrency | threading (non-blocking audio) |
| Chemistry Parser | Custom recursive tokenizer with regex |
- Python 3.7 or higher
- Windows OS (for
winsoundaudio β app runs without audio on other platforms) - No external libraries required (all standard library)
# Clone the repository
git clone https://github.com/Afra-Nawar-CS/bond-balancer.git
# Navigate into the folder
cd bond-balancer
# Run the app
python bond_balancer.pyThe leaderboard is automatically created as leaderboard.json in the same directory on first run, which is a persistent JSON leaderboard.
bond-balancer/
β
βββ bond_balancer.py # Main application (all features)
βββ leaderboard.json # Auto-generated on first run
βββ README.md # This file
Chemistry can feel intimidating, especially because of equation balancing, where students fail to remember how to use logical processes when they see complex compounds. I wanted to build something that showed the mathematical structure underneath chemical equations, while making practice genuinely engaging through competition and experimentation.
The gas reactor grew from my curiosity: what if students could experiment without a physical lab? On the other hand, The leaderboard was made after I remembered how hard students work when they are motivated to win a competition, because that same energy belongs in chemistry education as well!
- Expand equation database beyond 20
- Add organic chemistry reaction mechanisms
- Introduce 3D molecular visualisation
- Cross-platform audio (replace
winsound) - Web version for browser access
- Teacher dashboard for classroom leaderboard management
- More gas species and reaction types in Fizz Factory
This project was developed as an independent science fair entry exploring the intersection of computer science and chemistry education. The rational nullspace balancing algorithm was researched and implemented from first principles β no chemistry libraries were used.
Skills demonstrated:
- Algorithm design, stoichiometric prediction logic and linear algebra implementation
- GUI application development
- Object-oriented programming
- Data persistence and file I/O
- Multi-threading for responsive UI and threaded audio systems
- Chemistry domain knowledge (stoichiometry, reaction types, element classification)
Afra Nawar
Grade 9B Student | Cambridge O-Level Candidate 2027
Interests: Computational Chemistry, Computer Science, Environmental Technology
Open to feedback, collaboration, and questions about the algorithm.
MIT License β free to use, modify, and distribute with attribution.