In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Algorithms are used for calculation, data processing, and automated reasoning.

One tip of calculating the population of the new cell is to avoid doing addition for the eight surrounding cells each time. Instead, keep a counter and a few sums for left and right columns when you m …