July 6, 2024
Back in ye olde days when privateers were near the top of a sailor's concerns, flying a flag upside down was thought to be a way to signal to allied ships that you were in distress. Thatโs great news for the majority of countries, but for a select 14, and a few others, whose flags' mirror images are so similar to the original that you really canโt tell (looking at you, Great Britain), this was not possible.
Flying a flag upside down has since become a common form of protest (and, at one point, even ended up as a case in front of the supreme court!). This protest method has come up in a number of high profile occasions over the past few years (Jan. 6th, Overturning of Roe v Wade, Maro Lago FBI raid, and Justice Alito's home).
When discussing these events with a friend during a long car ride, we began joking about how this form of protest wouldnโt be possible in a country like Switzerland, since there is no one "correct" way to hang the flag (assuming you arenโt being a smart-ass and hanging it from a corner or something).
This, of course, led to a game of guessing which other flags would fall into this category of "unflippable," and this project idea was born.
I decided to use this as an excuse to try out Rust lang since there are some more advanced embedded project ideas that I want to work up to in the future.
The code basically loops through pixels in a flag, comparing them across the vertical and horizontal axis. At first I thought I was done with the project in the first few hours of working on it until I discovered Japan wasn't included in the fully symmetrical category!
Frustratingly, this was due to the structure of the png images I was getting back from the api. There were significant differences in many 1-to-1 pixel comparisons around the central circle, despite the area representing the mirrored curve.
I had to switch my approach to a fuzzy-match window that I could bring in as a secondary check when the 1-to-1 check failed. This was a bit of a doozy but a great learning experience (I see why people like this language so much).
-> you can find a csv of the detailed results on github
+----------------------------------------+-----+
| ๐ชฉ Flags with full symmetry | 14 |
+----------------------------------------+-----+
| โ๏ธ Flags with horizontal line symmetry | 23 |
+----------------------------------------+-----+
| โ๏ธ Flags with vertical line symmetry | 42 |
+----------------------------------------+-----+
| โ Flags with no symmetry | 173 |
+----------------------------------------+-----+
Full symmetry flags: ๐ต๐ช๐ฏ๐ฒ๐ฏ๐ต๐น๐ญ๐ซ๐ฒ๐ฑ๐ป๐จ๐ญ๐ง๐ผ๐ฎ๐ฑ๐ฆ๐น๐ฒ๐ฐ๐ฌ๐ฌ๐ณ๐ฌ๐ฌ๐ช
Horizontal line symmetry flags: ๐ฌ๐พ๐ฆ๐ฝ๐ต๐ผ๐ฌ๐ณ๐ฒ๐ซ๐ซ๐ด๐ฎ๐ช๐ซ๐ท๐ง๐ช๐ซ๐ฎ๐น๐ฉ๐ณ๏ธ๐จ๐ฎ๐ธ๐ช๐ฉ๐ฐ๐ง๐ญ๐ธ๐ฏ๐ฒ๐ฑ๐ฎ๐ธ๐ณ๐ด๐ถ๐ฆ๐ท๐ด๐ฎ๐น
Vertical line symmetry flags: ๐ฌ๐ฆ๐ธ๐ท๐ท๐ช๐ฎ๐ณ๐ธ๐ด๐ฒ๐ฆ๐ฑ๐น๐ท๐บ๐น๐ฏ๐ญ๐บ๐ฉ๐ช๐ฒ๐ฒ๐ป๐ณ๐ธ๐พ๐ณ๐ฑ๐ง๐ฌ๐ป๐ช๐ธ๐ฑ๐ฒ๐จ๐ฑ๐บ๐ญ๐ณ๐ฆ๐ฑ๐จ๐ด๐ฒ๐บ๐ฎ๐ฉ๐ฌ๐ญ๐ฌ๐ฒ๐ง๐ฎ๐ฒ๐ท๐ช๐ช๐บ๐ฆ๐ฑ๐ฆ๐ฆ๐ฌ๐ฒ๐ด๐ช๐บ๐ง๐ง๐ฑ๐จ๐ต๐ฑ๐ฆ๐ฒ๐จ๐ฆ๐ณ๐ช๐พ๐ช
No symmetry flags: ๐ฟ๐ผ๐น๐จ๐ญ๐ฐ๐ป๐จ๐ฆ๐ธ๐ณ๐บ๐ฎ๐ด๐ฑ๐พ๐ฒ๐ถ๐ง๐ฒ๐จ๐ฐ๐ง๐ฟ๐ธ๐ฌ๐ช๐ฌ๐ต๐ฆ๐ฟ๐ฆ๐ฐ๐ฌ๐ฏ๐ช๐ผ๐ซ๐ฌ๐ฎ๐ณ๐ท๐ฏ๐ด๐ต๐ญ๐บ๐ฟ๐ง๐ฉ๐ช๐ธ๐ญ๐ท๐ธ๐ง๐ช๐ญ๐ฐ๐ท๐น๐ฌ๐ฒ๐ณ๐ช๐น๐ณ๐ฎ๐น๐น๐ณ๐ซ๐จ๐ผ๐ธ๐ธ๐ง๐ฏ๐ฑ๐ฐ๐ง๐ด๐ฆ๐ฎ๐ต๐ฌ๐จ๐ป๐ฐ๐ต๐ฎ๐ท๐ธ๐ฎ๐ฆ๐บ๐ณ๏ธ๐ผ๐ธ๐ง๐ธ๐ณ๏ธ๐ง๐ซ๐ฒ๐ญ๐ฐ๐ฟ๐บ๐ณ๐ณ๐จ๐ต๐น๐จ๐ฑ๐ฌ๐ง๐จ๐ฌ๐ฌ๐ซ๐จ๐ฉ๐ฌ๐ต๐ญ๐น๐ฒ๐ช๐ฆ๐ผ๐ฒ๐ฝ๐ท๐ธ๐น๐ฒ๐ง๐ฆ๐ฒ๐น๐ฑ๐ฎ๐ฐ๐ฎ๐ซ๐ฐ๐ต๐ณ๐น๐ฐ๐ณ๐ฆ๐ฆ๐ฟ๐จ๐ท๐จ๐ฟ๐ฌ๐ฑ๐ธ๐ฝ๐ฆ๐ช๐จ๐ซ๐ณ๏ธ๐ฐ๐ฒ๐น๐ท๐ธ๐ฟ๐ฌ๐น๐ฒ๐ฌ๐จ๐ณ๐ฆ๐ท๐บ๐ธ๐ง๐ฑ๐ณ๐ต๐ฐ๐ผ๐ซ๐ฏ๐ณ๏ธ๐ฐ๐พ๐ฒ๐พ๐ฌ๐ธ๐ฌ๐บ๐พ๐น๐ต๐ซ๐ธ๐น๐จ๐พ๐ต๐ธ๐น๐ณ๐บ๐พ๐ฎ๐ฒ๐บ๐ฌ๐น๐ฑ๐ง๐ณ๐ณ๏ธ๐ฎ๐ถ๐ฒ๐ฉ๐ง๐น๐ง๐พ๐ช๐จ๐ธ๐ฉ๐ธ๐ฆ๐ด๐ฒ๐ฑ๐ง๐ฆ๐ถ๐ฐ๐ณ๐ฐ๐ช๐ฒ๐ผ๐ฌ๐ผ๐ช๐ท๐ฌ๐ถ๐ฉ๐ฒ๐ฐ๐ญ๐ธ๐ฒ๐ต๐ฐ๐ฝ๐ฐ๐ฉ๐ฏ๐น๐ผ๐ท๐ผ๐จ๐ฒ๐ฆ๐ฉ๐ธ๐ญ๐ป๐ฌ๐น๐ด๐ฆ๐ด๐ฌ๐ท๐ธ๐ป๐ฒ๐ฟ๐จ๐บ๐ธ๐จ๐ป๐ฆ๐ต๐พ๐ธ๐ฐ๐ฟ๐ฒ๐ฒ๐ธ๐น๐ป๐น๐ฟ๐ต๐ท๐ป๐ฎ๐ฉ๐ด๐ฉ๐ฟ๐ฒ๐ต๐ณ๐ฟ๐ฑ๐ท๐ป๐บ๐ฑ๐ธ๐ฌ๐ฉ๐ธ๐ณ๐ฒ๐ป๐ง๐ท๐ฆ๐ซ๐ณ๏ธ๐ต๐ฒ