Project 1: The “Homework Destroyer” (Equation Solver)
Build a solver that handles linear and quadratic equations and explains each step.
Project Overview
| Attribute | Value |
|---|---|
| Difficulty | Level 1: Beginner |
| Time Estimate | Weekend |
| Main Language | Python |
| Alternative Languages | JavaScript, C++ |
| Knowledge Area | Algebra |
| Tools | CLI, optional plotting |
| Main Book | “Algebra” by I.M. Gelfand |
What you’ll build: A CLI tool that solves equations like 2x+3=11 and x^2-5x+6=0, showing the steps.
Why it teaches math: Solving equations is the heart of algebra. Explaining steps proves you understand the rules.
Core challenges you’ll face:
- Parsing equation strings
- Applying algebraic transformations consistently
- Handling multiple solution cases
Real World Outcome
You will input an equation and get both the solution and a step-by-step explanation.
Example Output:
$ python solver.py "2x+3=11"
Step 1: subtract 3 from both sides -> 2x = 8
Step 2: divide both sides by 2 -> x = 4
Solution: x = 4
Verification steps:
- Test with multiple equation types
- Confirm solutions by substitution
The Core Question You’re Answering
“How can I turn algebra rules into a deterministic procedure a computer can follow?”
This project makes algebra mechanical and testable.
Concepts You Must Understand First
Stop and research these before coding:
- Equality transformations
- Why must you do the same operation to both sides?
- Book Reference: “Algebra” by I.M. Gelfand, Ch. 2
- Quadratic formula
- How does the discriminant determine the number of solutions?
- Book Reference: “Algebra” by I.M. Gelfand, Ch. 8
- Factoring basics
- When can you factor instead of using the quadratic formula?
- Book Reference: “Elementary Algebra” by Harold Jacobs, Ch. 6
Questions to Guide Your Design
- Parser strategy
- Will you parse with regex or a simple tokenizer?
- How will you handle missing multiplication symbols (like 2x)?
- Output clarity
- How will you format steps so they read like a textbook?
- How will you handle unsolvable or infinite solutions?
Thinking Exercise
Manual Solve
Solve 3x - 7 = 2x + 5 by hand and list each transformation step.
Questions while working:
- Which step isolates the variable?
- How do you check the result?
The Interview Questions They’ll Ask
Prepare to answer these:
- “Why do you apply the same operation to both sides?”
- “What does the discriminant tell you?”
- “How do you verify a solution?”
- “What is the difference between factoring and formula solving?”
- “How do you handle no-solution cases?”
Hints in Layers
Hint 1: Starting Point Handle only linear equations first.
Hint 2: Next Level Normalize equations into a standard form before solving.
Hint 3: Technical Details Implement a small tokenizer to avoid brittle string hacks.
Hint 4: Tools/Debugging Add tests that substitute the solution back into the equation.
Books That Will Help
| Topic | Book | Chapter |
|---|---|---|
| Linear equations | “Algebra” by I.M. Gelfand | Ch. 2 |
| Quadratics | “Algebra” by I.M. Gelfand | Ch. 8 |
| Factoring | “Elementary Algebra” by Harold Jacobs | Ch. 6 |
Implementation Hints
- Keep equation parsing simple and incremental.
- Always reduce to a canonical form before solving.
- Print steps in a consistent, human-friendly format.
Learning Milestones
- First milestone: You can solve and explain linear equations.
- Second milestone: You can solve quadratics reliably.
- Final milestone: You can handle edge cases and explain them.