Last Saturday, something went wrong with a real tournament schedule. Today we'll fix it — with code.
6 teams, 1 gym, 9 games at Akron-Fairgrove. Here's the real schedule:
North Huron had the 2nd game AND the last game — stuck at the gym for over 4 hours!
All 6 schools drove to Akron-Fairgrove. Some a LOT further than others.
Look at North Huron's games... then look at Akron-Fairgrove's games...
The school that drove the FURTHEST had to be there the LONGEST.
Think of rules that CAN'T be broken. Not suggestions — RULES.
Something that MUST be true. Not a suggestion.
Something you CAN'T do. A boundary you can't cross.
The shape the answer has to fit into.
In a tournament: two teams can't play on the same court at the same time. That's a constraint!
You already do constraint solving without realizing it!
Each row, column, and box must have 1–9 with no repeats. Those are the constraints!
"Don't put those two next to each other" and "everyone needs a seat" are constraints.
"Must fit in the bag" and "bring lunch AND homework" — constraints you solve every morning!
A constraint solver does the same thing you do — but it can try thousands of combinations in seconds.
Big companies use constraint solving every single day:
If YOU were making the schedule, what rules would you set?
Think about: playing too many games in a row, drive times, fairness...
You have 6 teams and 9 games. Can you arrange them so the rules aren't broken?
Take 2 minutes. Grab a piece of paper and try rearranging the 9 games. Can you make it fair for everyone?
A constraint solver begins by gathering all the facts and rules.
The solver loads these facts and rules into memory. Now it can start searching.
The solver tries different game orders and checks each one against every rule.
Each attempt gets a penalty score. The solver keeps the schedule with the lowest penalty.
Without rules, there are 362,880 possible orders for 9 games. Constraints eliminate most of them!
Each constraint is like a filter. The more rules you add, the fewer schedules survive — until you find the best one.
Shuffle the games into a random order
Does it break any rules? If yes, skip it.
How good is it? Lower penalty = better schedule.
The computer uses rules to narrow down the possibilities — that's constraint solving!
We fed the real schools, real distances, and our rules into a constraint solver...
Let's see what it came up with!
Think of 3 constraints in your life — and where else constraint solving could help!
Write down 3 constraints for something in YOUR life — bedtime, homework, screen time. What are the rules that can't be broken?
Each row, column, and 2×2 box must have 1–4 with no repeats.
Click Next Step to start solving!