Wolfram Computation Meets Knowledge

Flag Day

On June 14, 1777, the Continental Congress resolved that the flag of the United States would have 13 alternating red and white stripes, with the states represented as white stars on a blue field. The CountryData data paclet has information about this and many other flags, as can be seen in the “Country Flags and Descriptions” Demonstration.

Country Flags and Descriptions

If you’d like to test your knowledge of national flags, there is also a “Country Flag Quiz” Demonstration that you may download for free. Both of these Wolfram Demonstrations show off the power of the CountryData paclet. For example, Mathematica can analyze all those flag descriptions.
In[1]:= flags={#, Union[StringSplit[CountryData[#,"FlagDescription"] /. _Missing->"",RegularExpression["\\W+"]]]}&/@ CountryData[];
In[2]:= Grid[{#, Count[Flatten[flags], #]} & /@ {"red", "white", "blue", "green", "yellow", "black", "gold", "orange"}]

The code above gives a table of the number of times a particular color is used in a flag description. The three most-used colors in the flags of the world are red, white and blue.

Out[2]:= red 168, white 160, blue 122, green 96, yellow 88, black 49, gold 19, orange 11

Nineteen national flags include “isosceles” in their descriptions, and a bit of code can display them all.

In[4]:= Grid[Partition[CountryData[#, "Flag"] & /@ (First[flags[[#]]] & /@ First /@ Position[flags, "isosceles"]), 4, 4, 1, ""]]

Substituting “shield” for “isosceles” gives all the flags with shields.

In[5]:= Grid[Partition[CountryData[#, "Flag"] & /@ (First[flags[[#]]] & /@ First /@ Position[flags, "shield"]), 4, 4, 1, ""]]

The simple code below shows how similar two flags can be:

In[6]:= CountryData[#, "Flag"] & /@ {"Chad", "Romania"}

Mathematica is used in almost every country of the world, and even sometimes in outer space. Whatever your flag may be, I hope you’ve had fun with this piece of flag analysis.


Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.