Sébastien Rigaux

Packing algorithms in C#: from boxes to booking slots

ArticleC#
View resource

www.mostlylucid.net

This article puts several packing algorithms into practice in C#, from first fit and best fit to finding restaurant booking slots. It shows why sufficient total capacity does not guarantee a workable placement, and separates checking a solution from searching for a better arrangement.

The booking example uses half-open intervals and a sweep across occupied periods to find free slots. It also accounts for table turnaround time, showing how to incorporate a business constraint without changing the overlap rule.

The mostlylucid logo on a dark, circuit-patterned background, with the tagline “deep knowledge. cutting-edge craft”.