There are lots of very similar flags in the world, particularly the ones that are composed of three horizontal or three vertical bars. If we restrict ourselves to flags of one of these types, what is the longest path we can make by changing only one color at a time?

Q1: What is the longest path of flags composed of three horizontal bars?
Q2: What is the longest path of flags composed of three vertical bars?

Specification of rules:

  • A path of length $n$ consists of flags $F_1, \ldots, F_n$
  • Two flags are considered the same, if the colors of the corresponding bars only differ in shade and /or intensity.
  • No path may visit the same flag twice: $F_i \ne F_j$ whenever $i \ne j$
  • Neighboring flags in the path (flags $F_i$ and $F_{i+1}$) must differ in the color of exactly one bar.
  • Only flags of independent countries may show up in the path.
  • 2
    $\begingroup$ Is it allowed if there is a symbol in the middle (e.g. India, Argentina, Andorra etc.) or if the bars aren't exactly a third (Like Botswana, Columbia etc.)? And you probably want a clear definition of "independent country", like this or this. $\endgroup$
    – user10203
    Commented Mar 26, 2015 at 14:00
  • 1
    $\begingroup$ Do oceans join neighbours? i.e., is Canada a neighbour of France? Must all neighbouring flags differ in the colour of exactly one bar together, or individually on the path? i.e. if RWB -> RWG -> OWG were a path and RWB was adjacent to OWG, is that not allowed even though it isn't the path taken? $\endgroup$ Commented Mar 26, 2015 at 14:08
  • $\begingroup$ @IanMacDonald your questions are good - specifically for Canada and France, though, I invite you to consider Saint Pierre and Miquelon $\endgroup$
    – Joffan
    Commented Mar 26, 2015 at 14:29
  • $\begingroup$ I'm confused by what is meant by "path". I was thinking that @Martin was trying to stack flags next to each other, and "travel" down the "path" made by the flags. If that's not the case, how are we measuring paths from country to country? Center of the country? Capital of the country? Straight line distance, or can I travel a bit around countries to pad my path? And does "neighbor" mean arbitrarily adjacent flags in the path, or actual neighbors on the globe? $\endgroup$
    – Nick2253
    Commented Mar 26, 2015 at 15:15
  • $\begingroup$ surely he didnt mean on the globe. just the flag path i think. $\endgroup$
    – JLee
    Commented Mar 26, 2015 at 15:19

3 Answers 3


I counted 22 vertical flags (thanks to Nick2253 reminding me of Canada) and managed to put them in an order that appears to meet the rules..

enter image description here

The horizontal part: enter image description here

  • 1
    $\begingroup$ 8 and 9 do not match. You have to switch all 3 colors to get it. Also 9 and 10(2 colors), 10 and 11, 13 and 14, 14 and 15, 16 and 17, 18 and 19, 19 and 20 $\endgroup$
    – Novarg
    Commented Mar 26, 2015 at 15:40
  • $\begingroup$ @Novarg No, he only changed one color. Senegal and Afghanistan both contain red and green bars, and only differ from yellow to black. Until Martin provides any clarification to his question, this is clearly an allowable interpretation of his rule "differ in the color of exactly one bar". $\endgroup$
    – Nick2253
    Commented Mar 26, 2015 at 15:42
  • $\begingroup$ @Nick2253 oh, ok. As I understood it it was "only 1 bar can change color", so 2 other ones must remain same $\endgroup$
    – Novarg
    Commented Mar 26, 2015 at 15:43
  • $\begingroup$ @JLee I don't think Norfold Island qualifies as a sovereign country, as it is a territory of Australia. $\endgroup$
    – Nick2253
    Commented Mar 26, 2015 at 15:55
  • 2
    $\begingroup$ Ah, but what are different shades of the same color, and what are different colors? That's not as clear as it seems, especially when it comes to blue and green. They might look the same to you, but to a Russian, Mongolia and Cambodia are голубой, while the others are синий. $\endgroup$
    – KSmarts
    Commented Mar 26, 2015 at 16:27

Here's what I got for vertical stripes(assuming you may only change the color of 1 bar and 2 other bars must stay on their places):

enter image description here


I'm making the following assumptions:

  • A flag is composed of three horizontal bars or three vertical bars when the flag substantially (more than about 75%) is made up of three horizontal bars and three vertical bars. For example, Equatorial Guinea and Barbados are included, and Zambia and Antigua & Barbuda are not included.
  • Crests, shields, or symbols found on flags are ignored for both color and when considering if they have three horizontal or vertical bars. For example, Canada, Israel, Libya are included.
  • A horizontal or vertical bar, no matter how narrow, counts towards the bar count. This disqualifies, for example, North Korea, Kenya, and the Gambia.
  • The horizontal or vertical bars do not have to be the same size. The count is all that matters.
  • The horizontal or vertical bars do not have to be in the same order, as long as one color is different. For example, El Salvador's Flag (Blue, White, Blue) is a neighbor to Estonia's Flag (Blue, Black, White) because there is one bar different (Blue vs Black).
  • A sovereign nation is any state on this list.
  • Countries that have crosses on their flag do not count towards either horizontal or vertical bars. For example, Finland and Georgia are not included.

Under these rules, there are many solutions for the vertical-bar flags. There are a total of 22 countries with vertical-bar flags. In fact, you can actually make a continuous cycle of vertical-bar flags:

Vertical Flags

I'm working on Horizontal flags, and I'll get back on that.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.