This question was put on hold as off-topic because:
"...it appears to be a mathematics problem, as opposed to a mathematical puzzle." However, it is not a mathematics problem. There is no known mathematical solution. As one of the commenters already realized, the puzzle is to find a more efficient counting algorithm (likely using some coding language).

The goal is to find a counting algorithm that is better than simply recursing through every possibility, which will take a very long time. My implementation does it in just under 30 minutes, but I am very sure that other people can do it faster.

Below is a grid of the flags of the 70 countries with the largest population, in order from left to right, top to bottom. Both the upper left cell (the blue star) and the lower left cell (the green smiley) aren't flags. The flags don't serve any purpose for the question, other than to make the grid prettier, and drop some knowledge about population size by country.

Grid of Flags for the 70 most populous Countries

You must find the total number of paths that meet all of the following conditions:

Each path must
1. start in the blue star cell
2. end in the green smiley cell
3. visit each of the 70 flags exactly one time
4. move up, down, left, or right, but not diagonally

Here are a couple examples of valid paths:

enter image description here

enter image description here

  • 1
    $\begingroup$ I may be mistaken, but I believe this is an unsolved problem in combinatorics. $\endgroup$ – user20 Mar 11 '15 at 22:16
  • 1
    $\begingroup$ Related (but unanswered): stackoverflow.com/questions/14249499/… $\endgroup$ – Rand al'Thor Mar 11 '15 at 22:32
  • 1
    $\begingroup$ This would be a puzzle if you added a constraint (or multiple constraints) to the path. Top-of-my-head examples: Only move to a flag •...which shares a color; •... of a country with a smaller population; •...whose country name shares two letters. Of course, you'd then have to guarantee that there was such a path. $\endgroup$ – jscs Mar 11 '15 at 23:11
  • 1
    $\begingroup$ Correction: My C# solution found the answer it 29 minutes, 4.78 seconds, running on an i-7 $\endgroup$ – JLee Mar 12 '15 at 0:23
  • 5
    $\begingroup$ Is there any reason why the grid uses flags?? If not, I'd edit it down to a simple square. When I first saw this "puzzle", I thought it could hold potential - If there is some logical restriction in the flags (or associated countries.) Just paths is, well, boring. -1 (but no close-vote) from me. $\endgroup$ – BmyGuest Mar 12 '15 at 15:37

Browse other questions tagged or ask your own question.