The Pigeonhole Principle is one of the most obvious fundamentals in mathematics. It is so obvious that you may be surprised that there is even a name for it. It states that: "If n items are put into m containers, with n > m, then at least one container must contain more than one item." Alternatively, "If there are n items and m containers, with n > m, and only one item can fit in a container, then at least one item must remain out." For those who prefer visuals and really hate math: Even though the principle is simple it has been used to prove many complex mathematical theorems and lemmas. Here is one I find quite interesting: "Incompressible strings of every length exist." Alternatively, "There is a file of every size that your favorite zip program can't compress." The solution is left to the reader as an exercise. So, does the Pigeonhole Principle show up in programming. Of course it does. That's why
A blog on various topics in C++ programming including language features, standards, idioms, design patterns, functional, and OO programming.