Back to Spring 2026 Slide 1 / 17

Today's Mission Plan

15 min Slides — Constraints, the basketball problem, and how computers solve puzzles
10 min Discussion — What other problems could constraint solving fix?
65 min Game Time — Vertical Shooter, Cat Classroom, Gorilla Beat-Em-Up, or Firewall Escape
10 min Wrap Up — What did you learn? Where else could constraint solving help?
Constraint Solving

What If a Computer Could Plan Your Basketball Tournament?

Last Saturday, something went wrong with a real tournament schedule. Today we'll fix it — with code.

What Actually Happened — March 14, 2026

6 teams, 1 gym, 9 games at Akron-Fairgrove. Here's the real schedule:

10:00 AM Game 1 Cross Lutheran vs Akron-Fairgrove
10:30 AM Game 2 North Huron vs Caseville
11:00 AM Game 3 Mayville vs Owen-Gage
11:30 AM Game 4 Cross Lutheran vs Caseville
12:00 PM Game 5 Akron-Fairgrove vs North Huron
12:30 PM Game 6 Mayville vs Cross Lutheran
1:00 PM Game 7 Owen-Gage vs Caseville
1:30 PM Game 8 Akron-Fairgrove vs Mayville
2:00 PM Game 9 North Huron vs Owen-Gage

North Huron had the 2nd game AND the last game — stuck at the gym for over 4 hours!

How Far Did Everyone Drive?

All 6 schools drove to Akron-Fairgrove. Some a LOT further than others.

North Huron61 min · 50.5 mi
Caseville45 min · 36.6 mi
Cross Lutheran40 min · 31.2 mi
Owen-Gage32 min · 25.5 mi
Mayville31 min · 23.4 mi
Akron-FairgroveHOST · 0 min
Think About It

What's Wrong With This Schedule?

Look at North Huron's games... then look at Akron-Fairgrove's games...

Who drove the furthest?
Who was there the longest?
Who finished first?
The Answer

The Furthest Team Got the Worst Schedule

North Huron (Kinde)

Drive to tournament61 minutes
Distance50.5 miles
First game10:30 AM (Game 2)
Last game2:00 PM (Game 9)
Time at gym4+ hours
Home by~3:30 PM

Akron-Fairgrove (HOST)

Drive to tournament0 minutes
DistanceLives here!
First game10:00 AM (Game 1)
Last game1:30 PM (Game 8)
Done early?Yes!
Home byAlready there

The school that drove the FURTHEST had to be there the LONGEST.

New Word

What Is a Constraint?

Think of rules that CAN'T be broken. Not suggestions — RULES.

No running in the hall
Must wear shoes in gym
Can't be in two places at once
Game starts at 10:00 sharp
The Answer

A Constraint Is a Rule That Must Be Followed

A Rule

Something that MUST be true. Not a suggestion.

A Limit

Something you CAN'T do. A boundary you can't cross.

A Puzzle Piece

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!

Simple Example

Constraint Solving Is Like Sudoku

You already do constraint solving without realizing it!

Sudoku

Each row, column, and box must have 1–9 with no repeats. Those are the constraints!

Seating Chart

"Don't put those two next to each other" and "everyone needs a seat" are constraints.

Packing a Bag

"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.

Real World

Constraint Solving Is Everywhere

Big companies use constraint solving every single day:

Airlines — scheduling thousands of flights so pilots and planes are in the right place
Google Maps — finding the fastest route through traffic with turns, speed limits, and road closures
Schools — building class schedules so no teacher is in two rooms at once
Amazon — figuring out which truck delivers which package and in what order
Video Games — matching players of similar skill level in online games
Your Turn

What Constraints Should a Fair Tournament Follow?

If YOU were making the schedule, what rules would you set?

Think about: playing too many games in a row, drive times, fairness...

The Rules

Our Tournament Constraints

1 No team plays more than 2 games in a row — they need a break!
2 Far-away teams shouldn't have FIRST and LAST games — don't trap them all day
3 The host team should play later — they have no drive time
4 Everyone gets home around the same time — minimize the latest arrival
5 Every team plays the same number of games — fair for everyone
Challenge

How Would YOU Solve This?

You have 6 teams and 9 games. Can you arrange them so the rules aren't broken?

North Huron — 61 min
Caseville — 45 min
Cross Lutheran — 40 min
Owen-Gage — 32 min
Mayville — 31 min
Akron-Fairgrove — HOST
Trial and error?
Start with the farthest team?
Work backwards?
Draw a grid?

Try It!

Take 2 minutes. Grab a piece of paper and try rearranging the 9 games. Can you make it fair for everyone?

Step 1

Start With What We Know

A constraint solver begins by gathering all the facts and rules.

The Facts

6 teams
9 games (each team plays 3)
Games are 30 min apart
North Huron: 61 min drive
Caseville: 45 min drive
Akron-Fairgrove: 0 min (host)

The Rules (Constraints)

C1 No 3 games in a row
C2 Far teams get games close together
C3 Host team plays later slots
C4 Minimize latest arrival home
C5 Every team plays exactly 3 games

The solver loads these facts and rules into memory. Now it can start searching.

Step 2

Try, Check, Score

The solver tries different game orders and checks each one against every rule.

Attempt #1

NH plays Game 1, 5, 9
NH at gym from 10:00–2:30
Breaks rule C2 (far team spread out)
Penalty: HIGH

Attempt #437

NH plays Game 2, 3, 5
NH done by 12:30
AF plays Game 1 (breaks C3)
Penalty: MEDIUM

Attempt #8,241

NH plays Game 3, 4, 6
NH done by 12:30 — home by 1:30!
AF plays last game
Penalty: LOW

Each attempt gets a penalty score. The solver keeps the schedule with the lowest penalty.

Step 3

Constraints Narrow the Search

Without rules, there are 362,880 possible orders for 9 games. Constraints eliminate most of them!

362,880
All possible orders
~50,000
After C5 (3 games each)
~2,000
After C1 (no 3 in a row)
Best 1
After scoring C2, C3, C4

Each constraint is like a filter. The more rules you add, the fewer schedules survive — until you find the best one.

Constraint Solving

A Computer Can Check Thousands of Schedules in Seconds

1. Generate

Shuffle the games into a random order

2. Check

Does it break any rules? If yes, skip it.

3. Score

How good is it? Lower penalty = better schedule.

Repeat 10,000 times — keep the best schedule found so far!

The computer uses rules to narrow down the possibilities — that's constraint solving!

The Test

Can a Computer Actually Do Better?

We fed the real schools, real distances, and our rules into a constraint solver...

Let's see what it came up with!

The Result

The Computer's Schedule

Original Schedule

10:00 Cross Lutheran vs AF
10:30 Caseville vs NH
11:00 Mayville vs OG
11:30 Cross Lutheran vs Caseville
12:00 AF vs NH
12:30 Mayville vs Cross Lutheran
1:00 OG vs Caseville
1:30 AF vs Mayville
2:00 NH vs OG

Optimized Schedule

10:00 Mayville vs OG
10:30 AF vs Cross Lutheran
11:00 NH vs Caseville
11:30 NH vs OG
12:00 Caseville vs Cross Lutheran
12:30 NH vs Mayville
1:00 AF vs Caseville
1:30 OG vs Cross Lutheran
2:00 AF vs Mayville
NH done by 1:00 (not 2:30!) — home by 2:00
Caseville done by 1:30 — home by 2:15
NH away 4 hrs instead of 6 — saved 2 hours!
AF plays last game (lives there)
No team plays 3 in a row

Your Challenge

Think of 3 constraints in your life — and where else constraint solving could help!

Think About It

Write down 3 constraints for something in YOUR life — bedtime, homework, screen time. What are the rules that can't be broken?

School class schedules
Delivery truck routes
Seating charts
Meal planning
Video game matchmaking
Sudoku!