C++20 sections · 1024 units
Open in Course

George - The Pattern

Simple filtering

Here's what matters: for each room, you have two related numbers: current occupancy and maximum capacity. You can't evaluate one without the other. A pair keeps them together. I'll show you the condition.

A room works if capacity - occupancy >= 2. That's the free space. If there are at least 22 free beds, George and Alex can stay. Otherwise, the room doesn't work. This pattern appears often: you have paired data (price and quality, time and distance, input and output) and need to check a condition that involves both values.

Loop through the pairs and count matches.