Little Bobby Roberts, age 8, has been dragged to yet another museum by his parents. While they while away the hours studying Etruscan pottery and Warhol soup cans, Bobby must depend on himself for entertainment. Having a mathematical bent, he recently started counting all the square tiles on the floors of the museum. He soon realized that the tiles could be grouped into larger squares that needed to be added to the count. The problem became a bit more complicated when he started counting squares contained in multiple rooms, since some squares overlapped both rooms. For example, the two rooms shown below contain a total of 86 squares: 45 1 * 1 squares, 28 2 * 2 squares and 13 3 * 3 squares. (Note the opening between the two rooms is only 3 squares wide.)
While this helped kill several days' worth of museum visits, it soon became rather tedious, so Bobby is now looking for a program to automate the counting process for him.