Population Puzzle and Solution

Imagine groundhogs live together in cities. The imaginary 2017 groundhog survey puts populations of the 26 largest such cities at 18897109, 12828837, 9461105, 6371773, 5965343, 5946800, 5582170, 5564635, 5268860, 4552402, 4335391, 4296250, 4224851, 4192887, 3439809, 3279833, 3095313, 2812896, 2783243, 2710489, 2543482, 2356285, 2226009, 2149127, 2142508, and 2134411.

Requirement

Find a subset of these cities where a total of exactly 100,000,000 groundhogs live, assuming the survey is exactly right.

Reasoning

Pursued recursion because paper and pen algorithm work pointed to iterative accumulation and alternate solution paths at each iteration.

Avoided complexity by noting the requirement asked for "a subset" not "all subsets".

Returned the indices of the subset - not their values to avoid ambiguity in the case where populations could be identical.

Kept it simple and general and avoided possible undesirable effects by making the preference of which cities to include in the sum simply be the order of the cities as presented.

Implemented automated testing to support proof, future corrections, tuning and rewrites. If this puzzle were for serious software, automated testing should be required.

The City Populations in a Grid

Answer to Puzzle

Automated Testing