C++20 sections · 1024 units
Open in Course

Lessons from Domino piling

summary

This problem teaches you to look for mathematical shortcuts. When you see a geometric or counting problem, ask yourself: is there a direct formula? Simulation isn't always the answer.

Helper functions make simple calculations clearer. Even when your solution is one line of math, wrapping it in a named function documents what you're computing. maxDominoes(M, N) is more readable than (M * N) / 2.

Integer division handles remainders automatically. When you divide an odd area by 2, the result truncates to the floor. This matches the physical constraint: you can't place half a domino.