Working in software development, it is hard to turn off the logic center of the brain. Have you ever looked at a completely normal, everyday situation and thought, “Wait, there’s an algorithm for this”?

That happened to me recently on a simple bus ride.

I observed a family getting on the bus and trying to figure out their seating arrangement. Because of the way they sat, one child was left sitting alone. My brain immediately started crunching the numbers — mathematically, there was absolutely a way to seat them all safely.

I decided to turn this real-world observation into a custom coding problem. I call it The Bus Seating Problem.

The Scenario & Rules

Imagine an empty bus with paired seats. A group boards consisting of n adults (parents) and m children.

To make this a solid algorithmic challenge, here are some strict baseline constraints:

  • Both n and m are greater than 1 (at least 2 adults and 2 children).
  • The children always outnumber the adults (m > n).

Here are the survival rules for seating:

  • Two children can sit together safely.
  • No two adults can sit together.
  • A child cannot sit alone — they must sit with another child or an adult.
  • Adults can sit with children.

The Objective: Given n and m, is it possible to seat everyone safely?

You can find solutions in the everyday-algorithms repository on GitHub.