How many coaches does your school need for a trip to Croke Park?
Your school is heading to Croke Park. There are a hundred and eighteen people going, and each coach has fifty passenger seats. How many coaches should you book so everyone gets a seat?
Start with two numbers: how many people are going, including teachers, and how many passenger seats each coach has. All coaches have the same capacity. Everyone needs a seat, and your goal is to book the fewest coaches that meet that constraint.
Keep the capacity at fifty seats per coach. With a hundred people, you fill two coaches and nobody is left waiting. With a hundred and one, you still fill two coaches, but one person is left. Add one coach whenever anyone is left waiting.
You have eighty-one people going and forty seats per coach. Two full coaches seat eighty people. How many coaches should you book in total so everyone has a seat? Pick the smallest number that works.
An algorithm is a finite set of precise instructions. Break this task into three smaller jobs: count, decide and check. Now refine the counting job. Work out how many coaches you can fill and how many people are left. The number left is called the remainder.
For a hundred and eighteen people, dividing by fifty gives two full coaches with eighteen people left. Add one coach. Now check both sides of the decision: three coaches seat a hundred and fifty, which is enough, while two seat only a hundred, which is too few.
Another group has a hundred and thirty-two people, and each coach has forty-four seats. This time the group might fit exactly. Use the same rule as before and pick the fewest coaches the school needs.
A calculator gives two point three six when you divide a hundred and eighteen by fifty. Rounding to the nearest whole number gives two, leaving eighteen people without seats. Use three coaches instead. For this problem, any positive remainder means you need another coach.
A program can divide and test the remainder. For a hundred and eighteen people, it adds one to two. Or it can subtract fifty and count each subtraction. The third subtraction takes the total below zero, so it stops at three coaches. Across many groups, division avoids a loop step per coach.
If asked to describe an algorithm and illustrate its operation, use a new group. With a hundred and fifty-one people and fifty seats per coach, three coaches fill up, leaving one person. Add one coach if the remainder is positive. Four seat two hundred, while three seat only a hundred and fifty.