There have been many other flag challenges posted but not one for the national flag of France. This week seems like an appropriate time.

Produce this flag in the fewest bytes possible:

French flag

  • The image must be in a ratio of 3:2, with size at least 78 pixels wide and 52 pixels tall.
  • Each stripe takes up one third of the width.
  • The stripe colors from left to right are RGB: (0, 85, 164), (255, 255, 255), (239, 65, 53).
  • The image can be saved to a file or piped raw to STDOUT in any common image file format, or it can be displayed.
  • Alternatively, output a block of text at least 78 characters wide made of non-whitespace characters that depicts the flag, using ANSI color codes to color it. (Use standard blue, white, and red.)
  • Built-in flag images/libraries are not allowed.

The shortest code in bytes wins.


The Stack Snippet at the bottom of this post generates the leaderboard from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:

## [><>](http://esolangs.org/wiki/Fish), 121 bytes

<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table><script>var QUESTION_ID = 64140; var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk"; var OVERRIDE_USER = 42156; var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page; function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; } function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; } function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { data.items.forEach(function(c) { if (c.owner.user_id === OVERRIDE_USER) answers_hash[c.post_id].comments.push(c); }); if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); } getAnswers(); var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/; var OVERRIDE_REG = /^Override\s*header:\s*/i; function getAuthorName(a) { return a.owner.display_name; } function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>'; }); var match = body.match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2], language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery('<a>'+lang+'</a>').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) return -1; return 0; }); for (var i = 0; i < langs.length; ++i) { var language = jQuery("#language-template").html(); var lang = langs[i]; language = language.replace("{{LANGUAGE}}", lang.lang) .replace("{{NAME}}", lang.user) .replace("{{SIZE}}", lang.size) .replace("{{LINK}}", lang.link); language = jQuery(language); jQuery("#languages").append(language); } }</script>

  • 4
    \$\begingroup\$ Those RGB values don't match your image. From what I see, you've got RGB: (0, 35, 149), (255, 255, 255), (237, 41, 57). \$\endgroup\$ – beaker Nov 18 '15 at 0:18
  • 8
    \$\begingroup\$ Storing the specified palette compactly is probably the trickiest part of this problem in most languages. Given that, it seems rather unfair to graphical solutions to permit ANSI output with a standard palette. Why not permit graphical solutions to use pure (0, 0, 255)/(255, 255, 255)/(255, 0 0) to level the playing field? \$\endgroup\$ – JohnE Nov 18 '15 at 0:19
  • 15
    \$\begingroup\$ Each stripe takes up one third of the width. Might be more interesting to use the Naval variant: by a regulation dated 17 May 1853, the navy went back to using the 30:33:37 proportions, which it now continues to use, as the flapping of the flag makes portions farther from the halyard seem smaller. \$\endgroup\$ – Ben Jackson Nov 18 '15 at 0:19
  • 36
    \$\begingroup\$ echo 🇫🇷 not quite big enough \$\endgroup\$ – Digital Trauma Nov 18 '15 at 4:08
  • 5
    \$\begingroup\$ @JohnE I agree. The rules on colors give the ASCII-art solutions a massive advantage. They also don't make the challenge any more "difficult" (merely adds bytes really) for the languages that can use arbitrary colors and disqualifies several cool languages that can't do arbitrary colors. \$\endgroup\$ – a spaghetto Nov 18 '15 at 22:26

86 Answers 86


Googly Blockly, 45 blocks

Blockly source code


Blockly output

Try it here


Powershell, 173 bytes, 170 bytes, 155 bytes, 97 bytes!

$i=26;$y=0;function w($c){for($x=0;$x -le $i; $x++){write-host -noNewLine "F" -ForegroundColor $c}}for($x=0;$x -le $i; $x++){w("blue");w("white");w("red");write-host '';}

sal q write-host;$i=26;$y=0;function w($c){for($x=0;$x -le $i; $x++){q -noNewLine F -ForegroundColor $c}}for($x=0;$x -le $i; $x++){w("blue");w("white");w("red");q '';}

(Thanks to Cole Johnson for saving me 15 bytes):

sal q write-host;$i=26;function w($c){for($x=0;$x -le $i; $x++){q -noNewLine F -ForegroundColor $c}}for($x=0;$x-le$i;$x++){w("blue");w("white");w("red");q}

(Thanks Steve for saving me 58 bytes!!!)

sal q write-host;function w($c){1..26|%{q -noNewLine F -Foreground $c}}1..26|%{w(9);w(7);w(12);q}



My first code golf, so I hope I didn't do something wrong.

  • \$\begingroup\$ You could trim six bytes by removing the spaces before $x++ (2) and the spaces in $x -le $i (4) making the for declaration for($x=0;$x-le$i;$x++). Four more bytes by replacing q ''; at the end with just q. Also, where is $y used? Removing $y=0 will save you another four. Screenshot of edit \$\endgroup\$ – Cole Johnson Nov 20 '15 at 6:13
  • \$\begingroup\$ Get rid of $i and make use of 1..26|%{....}, dropping you from 155 bytes to just 115. sal q write-host;function w($c){1..26|%{q -noNewLine F -ForegroundColor $c}}1..26|%{w("blue");w("white");w("red");q} \$\endgroup\$ – steve Nov 24 '15 at 23:10
  • \$\begingroup\$ Save 5 more by replacing ForegroundColor with the shorter Foreground. \$\endgroup\$ – steve Nov 24 '15 at 23:21
  • \$\begingroup\$ Lose the wordy color descriptions too, use numbers. All the above then gives you 97 bytes (yay, we broke the 100 barrier!) sal q write-host;function w($c){1..26|%{q -noNewLine F -Foreground $c}}1..26|%{w(9);w(7);w(12);q} \$\endgroup\$ – steve Nov 24 '15 at 23:28
  • 2
    \$\begingroup\$ How about @("█"*26)*30|%{sal w write-host;w $_ -f 9 -n;w $_ -n;w $_ -f 4} at 63 bytes \$\endgroup\$ – TessellatingHeckler Dec 18 '15 at 23:58

ZX Spectrum BASIC, 10 bytes

(including the final end-of-line)

This does not fulfil the minimum flag size requirement, but I like this version, because it is so nice and compact. Please take it as a non-competing entry.

PRINT "▌▌"

The hexadecimal dump is: F5 22 10 01 8A 10 02 8A 22 0D


PRINT is a keyword and takes one byte, 0xF5, it's graphical representation includes the spaces around. The ZX Spectrum BASIC has one-byte colour codes, introduced by the 0x10 code for the foreground - 01 is for blue, 02 for red. 0x8A is a pseudographical character "▌", the left part of which is displayed in either blue or red.

The colours are of course from the standard ZX Spectrum palette - please adjust your PAL TV if the RGB values are not displayed quite correctly.

Despite the seemingly text mode of the program, the output is fully (bitmapped) graphical, as can be seen by looking into the VideoRAM. Thus there is no need to comply with the ANSI codes requirement, which the ZX does not support anyway (it has superior INK and PAPER commands).

  • \$\begingroup\$ Any chance of a link to an emulator/interpreter? \$\endgroup\$ – user45941 Nov 21 '15 at 12:45
  • 2
    \$\begingroup\$ Presumably a full flag would me something like FOR i=SGN PI TO PI*PI+PI+PI: PRINT "<blue ink>[8 blocks]","<red ink>[8 blocks]": NEXT i \$\endgroup\$ – Neil Nov 22 '15 at 23:20

x86 machine code, 34 bytes

00000000  68 00 b8 07 bb 40 1f 31  ff 83 e7 f0 89 d8 25 00  |h....@.1......%.|
00000010  f1 c1 c3 04 f6 c4 f0 74  f0 b1 1b f3 ab 85 ff 7f  |.......t........|
00000020  eb c3                                             |..|

Link to the .COM file - runs just fine in DOSBox:

sample output

Notice that it doesn't hang after drawing - it's just that the prompt is left in blue not to ruin the result; you can quit from DOSBox as usual with exit, it'll work even if you don't see it while typing.

Commented assembly:

    ; usual .COM boilerplate
    org 100h

section .text

    ; point the ES segment to the graphics memory
    push 0x0b800
    pop es
    ; bx is used (mainly) as repository for the background colors
    ; 1 => blue; f => white; 4 => red; 0 => flag for new row
    mov bx,0x1f40
    ; reset the destination pointer
    xor di,di
    ; === start of a new row ===
    ; round down DI to multiples of 16, to avoid overflowing the row by one
    ; character (27*3 = 81, while the row is 80 characters)
    and di,0xfff0
    ; === start of a span ===
    ; build the pattern to write; start with BX
    mov ax,bx
    ; adjust the pattern in AX:
    ; - keep the upper byte (background color);
    ; - leave blue as foreground color at the very end (avoid the prompt
    ;   ruining the flag when we exit);
    ; - put NUL as character to display;
    and ax,0xf100
    ; rotate bx, to switch to the next color pattern
    rol bx,4
    ; check if we got to the sentinel value (=> we finished one row)
    test ah,0xf0
    ; in this case, go back to newrow; this will re-align DI and do a new
    ; rotation on BX
    jz newrow
    ; fill the video memory with 27 times the word built above in AX
    mov cl,27
    rep stosw
    ; continue as far as DI is positive; notice that this way we keep writing
    ; well past the 25 lines limit, but doesn't seem to impact anything
    test di,di
    jg span
    ; otherwise exit; the point of this thing is to avoid a wraparound, which
    ; ends up unaligned, thus breaking the drawing
  • \$\begingroup\$ It's backwards. And I don't think the color are right. \$\endgroup\$ – lirtosiast Nov 24 '15 at 1:34
  • \$\begingroup\$ @ThomasKwa: sorry, order fixed; the colors are what the nearest that are available in the default VGA palette. \$\endgroup\$ – Matteo Italia Nov 24 '15 at 1:36

Marbelous, 122 bytes


Main board calls Ro 52 times. Ro prints one row including 3 color codes, 3 blocks of spaces, 1 color reset, 1 newline. Bl prints 26 spacesFs. PS prints one space F.


Befunge-98, 170 bytes

a"552"a"25 87"a"3P"ck,dd+20pv
_v#p02:-1g02,k8"0 85 164 "  <
<_v#p02:-1g02,k3"255 "
v >dd+20p
>" 35 56 932"9v>
v >"<"00pdd+20p

Outputs the image in PPM format. It's probably still not optimal.


Unix Shell, 57 bytes.

for i in {a..z}
do printf ␛[4%-28s 4m 7m 1m
echo ␛[m

The escapes are in the script literally. On most color terminals you can change 47 to 107 to get a brighter white, but that's not ANSI standard. The script ends up being 61 bytes then. The 28 rather than 26 is because the color code 'steals' two characters from the field width.

Obligatory xxd dump:

0000000: 666f 7220 6920 696e 207b 612e 2e7a 7d0a  for i in {a..z}.
0000010: 646f 2070 7269 6e74 6620 1b5b 3425 2d32  do printf .[4%-2
0000020: 3873 2034 6d20 376d 2031 6d0a 6563 686f  8s 4m 7m 1m.echo
0000030: 201b 5b6d 0a64 6f6e 65                    .[m.done

On a terminal that supports 8-bit control codes it can be made slightly shorter, for 55 bytes.

0000000: 666f 7220 6920 696e 207b 612e 2e7a 7d0a  for i in {a..z}.
0000010: 646f 2070 7269 6e74 6620 9b34 252d 3238  do printf .4%-28
0000020: 7320 346d 2037 6d20 316d 0a65 6368 6f20  s 4m 7m 1m.echo
0000030: 9b6d 0a64 6f6e 65                        .m.done

EDIT: It has come to my attention that ANSI-based solutions are required to draw text in non-white space characters. I have a solution of 65 characters that does so, but I would like someone to explain the reason for the requirement before I post it.

  • \$\begingroup\$ Can you share an xxd dump or base64 decode of this? \$\endgroup\$ – Digital Trauma Nov 18 '15 at 16:25
  • \$\begingroup\$ @DigitalTrauma I really don't think that should be necessary for only two characters where it's perfectly clear where and what they are, but fine. \$\endgroup\$ – Random832 Nov 18 '15 at 16:59
  • \$\begingroup\$ Thanks - I asked because it wasn't working for me when copied from this page. It works great with the xxd dump. I think the markdown is translating ␛to 0xe2909b, instead of the necessary 0x1b. \$\endgroup\$ – Digital Trauma Nov 18 '15 at 18:52
  • \$\begingroup\$ @DigitalTrauma I deliberately placed the ␛ symbol to indicate the presence and location of the escape characters, I intended for anyone trying to run this to use their editor's mechanism (^V, ^Q, etc) to replace them with literal escapes. Placing literal escapes on the answer itself caused them not to show up at all. \$\endgroup\$ – Random832 Nov 18 '15 at 18:54
  • \$\begingroup\$ This doesn't use the correct RGB values, does it? \$\endgroup\$ – Doorknob Nov 18 '15 at 22:17

CBM BASIC 7.0, 76 bytes

3fOj=1to26:?" ";:nE:reT

Note that in line 1, the characters between the quotation marks are PETSCII control codes which actually appear in reverse video on a real Commodore computer:

  • r enables reverse video
  • changes the text colour to blue
  • e changes the text colour to white
  • £ changes the text colour to red

It's not strictly ANSI, as specified in the question, but given the hardware limitations I think it's close enough. :)

Here is an excerpt of the output on a Commodore 128 80-column display:

a French flag, as produced by the above code on a Commodore 128


Javascript, 91 bytes

Not the most exciting one.

This one only works on Google Chrome. Current version is 46.0.2490.86m.


This draws the flag in the console.

Google Chrome has a pure white background for the console, and the default font weight allows it to have 33% of it's width.

This uses the BLACK VERTICAL RECTANGLE character to produce the output.

If you don't have Google Chrome, here's the output:


As an alternative, with 84 bytes:


This one uses the FULL BLOCK UTF8 character (\xDC in ASCII).

It produces a ~13x9cm flag on Chrome's console.

And this is the result:



QBASIC, 88 122 Bytes

PALETTE 2,856123
PALETTE 1,2626816

Edit: As was correctly pointed out, the colors did not meet the requirements. The corrected version is basically as close as one can get in QB as far as I know, since RGB in mode 13 are represented by 18 bits instead of 24 bit. The colors are (0,85,162), (255,255,255), (239,65,52). So blue is ever so slightly off the mark, but close enough I would say.

Here is it in QB64 (it's getting autoformatted there, but it's the same code): enter image description here

  • \$\begingroup\$ You could make the image slightly smaller (e.g. 96x64) to save a few bytes. The colors aren't quite right, though. \$\endgroup\$ – primo Nov 19 '15 at 23:37
  • 1
    \$\begingroup\$ @primo You are right about the colors. I fixed them as best as possible at the cost of 34 bytes. In the spirit of the underlying occasion of this challange, I ignore the possible 3 saved bytes for the increased size. \$\endgroup\$ – Jens Nov 20 '15 at 1:45

CSS, 86 bytes

This creates a simple border around the body element:

body{border-left:2cm solid #0055a4;width:2cm;height:4cm;border-right:2cm solid #ef4135

This renders a 6x4cm flag, and should work on any file.

To test on a clean page, paste this on your address bar:

data:text/html,<style>body{border-left:2cm solid #0055a4;width:2cm;height:4cm;border-right:2cm solid #ef4135



  • \$\begingroup\$ You could use a variant of the lobotomized owl selector and replace that body with *>* (or its not as cool cousin, * *) to save 1 byte. Also, you could remove the spaces before hex colors and save another 2 bytes off that. That's a total of 83 bytes: *>*{border-left:2cm solid#0055a4;width:2cm;height:4cm;border-right:2cm solid#ef4135 \$\endgroup\$ – Matheus Avellar Aug 13 '17 at 2:32

Python, 223 208 bytes

Thanks @Sp3000

from turtle import*
def D():fill(1);fd(100);rt(90);fd(200);rt(90);fd(100);rt(90);fd(200);rt(90);fill(0)

Try it here

  • 2
    \$\begingroup\$ Put the entire D function on one line, with semicolons separating each call. That'll shave off 10 bytes. Get rid of the extraneous space between the last setpos and its arguments for an extra byte. \$\endgroup\$ – user45941 Nov 18 '15 at 5:06
  • 3
    \$\begingroup\$ This also doesn't work. \$\endgroup\$ – user45941 Nov 18 '15 at 5:08
  • \$\begingroup\$ You can remove the space between import and * \$\endgroup\$ – undergroundmonorail Nov 18 '15 at 13:24
  • \$\begingroup\$ @Mego now it does. \$\endgroup\$ – TanMath Nov 18 '15 at 19:12
  • \$\begingroup\$ @undergroundmonorail it ha already been removed. \$\endgroup\$ – TanMath Nov 18 '15 at 19:13

Java, 156 bytes

enum F{;public static void main(String[]a){String b="[3";for(int i=0;i<'࿘';i++)System.out.print((i%78<26?b+4:(i%78>51?b+1:b+7))+(i%78>76?"m#\n":"m#"));}}

enter image description here

Used some old tricks like the unicode char used as an int in the loop and so earning a character (but not a byte), modulos (so there's only one loop) and some ternary expressions.

Nothing really special else.

  • 1
    \$\begingroup\$ Feel free to revert if you want; I removed your character count because this question is scored by bytes. \$\endgroup\$ – lirtosiast Nov 24 '15 at 1:40

CSS, 74 72 bytes

Note: every CSS code is also a valid Sass code: since Sass is a scripting language then this entry should be valid too :)


*{box-shadow:33.3vw 0 #0055a4 inset,-33.3vw 0 #ef4135 inset;height:66.6vw}

The correct ratio is ensured by the height, expressed as 2/3 of the viewport width (clearly this lacks precision when the viewport is larger than 999px, but at least it is responsive :D )

Edit 1: (72 bytes) from the previous example, a space can be safely removed before each colour.


*{box-shadow:33.3vw 0#0055a4 inset,-33.3vw 0#ef4135 inset;height:66.6vw}


enter image description here

Note that with less code (68 bytes, since decimals are not needed in the box-shadow) it is possible to draw the 1853 naval variant, in 30:33:37 proportions, as suggested in a comment above

*{box-shadow:30vw 0#0055a4 inset,-37vw 0#ef4135 inset;height:66.6vw}
  • \$\begingroup\$ To save yet another byte, you can remove the last }. Also, using 66.6% may produce the same result. \$\endgroup\$ – Ismael Miguel Dec 1 '15 at 9:38

ZX Spectrum Z80 assembly, 32, 30 Bytes

    org 8000h  

red:      equ 16   
white:    equ 120  
blue:     equ 8  

    ld    c,16     ;height
    ld    e,8      ; blue/offset/counter
    ld    hl,5800h
    ld    b,e      ;counter
    ld    (hl),e   ;blue
    inc   hl
    djnz  fun
    ld    b,e      ;counter
    ld   (hl),white
    inc  hl
    djnz with
    ld   b,e       ;counter
    ld   (hl),red
    inc  hl
    djnz flags
    ld   d,b       ;e holds offset       
    add  hl,de
    dec  c
    jr   nz,sheldon


    30 bytes

output is 24*8 pixels wide =192 pixels wide
and 16*8 pixels high =128 pixels high

edit 1: removed preload of de with two colours,shorter to directly load (hl):saves 1 byte
By not using "de" it can now transfer values instead of "a":saves 1 byte

enter image description here


Mathematica, 131 bytes


Saves to a file named .png in the current working directory.

  • 2
    \$\begingroup\$ Does Mathematica not have some sort of country flags built-in? \$\endgroup\$ – Skyler Nov 18 '15 at 14:33
  • \$\begingroup\$ @Skyler "Built-in flag images/libraries are not allowed." Besides, Mma's flag uses a different blue color. \$\endgroup\$ – LegionMammal978 Nov 18 '15 at 22:09

Javascript, 109 98 96 91

Attempt 1 109

var i=0,a='%cFRANCE',b='color:#';for(;i<6;i++)console.log(new Array(4).join(a),b+'0055A4',b+'FFF',b+'EF4135')

Attempt 2 98

for(var i=0;i<6;i++)console.log('%cFRANCE'.repeat(3),'color:#0055A4','color:#FFF','color:#EF4135')

Attempt3 120


Attempt 3 solves the issue with chrome forcing them together still attempt 2 works for me in ff.

No longer and issue just enable time stamps in options for console logging.

Attempt 4 96

var i=0,c='color:#';for(;i<6;i++)console.log('%cFRANCE'.repeat(3),c+'0055A4',c+'FFF',c+'EF4135')

Attempt 5 91


Moved var decs into for loop saved 5 bytes :D

Try it out here :).



Scala, 84 bytes

Using ANSI colors, Running on bash (Ubuntu)

val (p,b)=("\033[;3","\u2588"*26);(1 to 52).map(_=>println("471".mkString(p,"m"+b+p,"m"+b)))

Ruby, 77 bytes

puts"P3\n78 52\n255","#{"0 85 164 "*26+"255 255 255 "*26+"239 65 53 "*26}"*52

Output (converted to png, since ppm doesn't seem to be supported):

enter image description here

Outputs in ppm format to STDOUT. Still working on plusgolfing. I know ppm can take bytes instead of ascii, but I haven't figured out a good way to do that yet.

  • \$\begingroup\$ PPM doesn't require newlines. Replace \n with spaces to save 2 chars overall. (Alternatively, you could literally put a newline in the string, which Ruby allows, to save the same amount. \$\endgroup\$ – Doorknob Nov 19 '15 at 1:37

PostScript, 128 bytes.

<</PageSize[78 52]>>setpagedevice
0 .333 .643 setrgbcolor
0 0 26 52 rectfill
.937 .255 .208 setrgbcolor
52 0 26 52 rectfill

Questionable PS version, 84 bytes

0 .33 .64 setrgbcolor
0 0 26 52 rectfill
.94 .25 .21 setrgbcolor
52 0 26 52 rectfill

This may not have exact color matches (though they should be indistinguishable to the human eye), may render in the corner of a larger page, and some interpreters may not accept it without the magic line at the beginning.

I can't test right now, but it may be possible to save some bytes by using a subroutine:

/a{setrgbcolor rectfill}def
0 0 26 52 0 .33 .64 a
52 0 26 52 .94 .25 .21 a

/a{setrgbcolor rectfill}def
0 0 26 52 0 .33 .64
52 0 26 52 .94 .25 .21<</PageSize[78 52]>>setpagedevice
a a
  • \$\begingroup\$ Save some bytes by removing the first two lines and shortening the numbers a digit. Then it comes to 90 bytes. Even though technically invalid, at least ps2pdf renders it correctly. \$\endgroup\$ – firefrorefiddle Nov 18 '15 at 15:21
  • \$\begingroup\$ If I remove the second line it renders in the bottom left corner of a larger page. I didn't do a color matching test, but I assumed I would need three digits to get sufficient precision within 1/255 unit. \$\endgroup\$ – Random832 Nov 18 '15 at 15:23

Ruby with Shoes, 119 bytes

Shoes.app(width:78,height:52){strokewidth 0
fill c

Sample output:

French Tricolour


C-Sharp, 4608, 1312, 687, 606 bytes

Paris Flag

Thanks for your comments and suggestions. This is actually my first "published" piece of code ever! have been learning for about two-and-a-half months.

class P { static void Main(string[] args) { int l = 0; while (l < 24) { int B = 0; int R = 0; int W = 0; while (B < 26) { Console.BackgroundColor = ConsoleColor.DarkBlue; Console.Write(" "); B++; } while (W < 26) { Console.BackgroundColor = ConsoleColor.White; Console.Write(" "); W++; } while (R < 26) { Console.BackgroundColor = ConsoleColor.Red; Console.Write(" "); R++; } Console.WriteLine(); l++; } Console.BackgroundColor = ConsoleColor.Black; Cons‌​ole.ReadKey();}}
  • 2
    \$\begingroup\$ You've still got a few more spaces to get rid of. In addition, I don't believe the namespace is necessary (I could be mistaken), and all of your variables (as well as the class name and namespace name, if it's necessary) should be shortened to one-character names. \$\endgroup\$ – user45941 Nov 19 '15 at 16:45
  • 2
    \$\begingroup\$ Remember, your entry does not have to be human-readable. Just simple search-and-replace makes your entry fit in a comment: class P{static void Main(string[] args){int l=0;while(l<24){int B=0;int R=0;int W=0;while(B<26){Console.BackgroundColor=ConsoleColor.DarkBlue;Console.Write(" ");B++;}while(W<26){Console.BackgroundColor=ConsoleColor.White;Console.Write(" ");W++;}while(R<26){Console.BackgroundColor=ConsoleColor.Red;Console.Write(" ");R++;}Console.WriteLine();l++;}Console.BackgroundColor=ConsoleColor.Black;Console.ReadKey();}}. Can't help you with C# specific tricks, though. \$\endgroup\$ – Sanchises Nov 19 '15 at 19:45
  • 3
    \$\begingroup\$ The using keyword would help you shave off a lot of bytes. If you put "using C=System.Console;" at the top of your code you can replace every occurrence of Console by C. Similarly for ConsoleColor. \$\endgroup\$ – Tom van der Zanden Nov 20 '15 at 9:16
  • 1
    \$\begingroup\$ Assign your three variables in one statement: int B=0;int R=0;int W=0; -> int B=0,R=0,W=0; (-8 bytes). Convert your outer while loop to a for (-2 bytes). Only saves a few bytes, but everything counts. \$\endgroup\$ – ChicagoRedSox Nov 21 '15 at 6:58
  • 1
    \$\begingroup\$ Some more tips: Don't use 3 separate loops, instead: using b=System.ConsoleColor; foreach (var c in new[] { b.DarkBlue, b.White, b.Red }). Use composite formatting to output 26 spaces in one go: using a=System.Console; a.Write("{0,26}", ' ');. Doing this, and implementing the other's tips, I was able to cut it down to 210 bytes! \$\endgroup\$ – Berend Nov 24 '15 at 13:51

Octave, 58 bytes

The online Octave interpreter seems to scale up by default, so the Octave answer is rather short, especially since you can use inline assignment.

imshow([c=cat(3,[0 m=255 239],[85 m 65],[164 m 53]);c]/m);


MATLAB, 70 bytes

Since I'm not entirely sure if it's just the online interpreter doing the scaling or whether that's an actual language feature in my Octave answer, here's my MATLAB version as well:

m=255;c=cat(3,[0 m 239],[85 m 65],[164 m 53]);imshow([c;c]/m,'I',6e3);

I stands for InitialMagnification.

MATLAB answer


JavaScript 206 175

<canvas id=c></canvas>

Here's something just for fun. The code can be modified to make all images on a page the french flag.

function france(g){
  var c =document.createElement('canvas')
  var x = c.getContext('2d');
  var w = c.width = g.width;
  var h = c.height = g.height;
  var d = x.createImageData(w,h);
  var a = new Int32Array(d.data.buffer);
  var s = w / 3;
  for(var i=w*h;i--;)a[i]=-[6007552,1,13286929][i%w/s|0];
  g.src = c.toDataURL();

function allFrance() {
  var g = document.getElementsByTagName("img");
  for(var i = g.length; i--;) france(g[i]);

  • \$\begingroup\$ use c instead of document.getElementById('c'). Also remove the new keyword. \$\endgroup\$ – Mama Fun Roll Nov 21 '15 at 19:48
  • \$\begingroup\$ Thansk @ןnɟuɐɯɹɐןoɯ it worked! \$\endgroup\$ – wolfhammer Nov 21 '15 at 21:24

FLTK, 234 199 bytes

Function{}{}{Fl_Window{}{xywh{9 9 78 52}}{Fl_Box{}{xywh{0 0 26 52}box FLAT_BOX color 0x0055a4ff}Fl_Box{}{xywh{26 0 26 52}box FLAT_BOX color 7}Fl_Box{}{xywh{52 0 26 52}box FLAT_BOX color 0xef4135ff}}}


Function {} {} {
    Fl_Window {} {
        xywh {9 9 78 52}
    } {
        Fl_Box {} {
            xywh {0 0 26 52}
            box FLAT_BOX
            color 0x0055a4ff
        Fl_Box {} {
            xywh {26 0 26 52}
            box FLAT_BOX
            color 7
        Fl_Box {} {
            xywh {52 0 26 52}
            box FLAT_BOX
            color 0xef4135ff

Sample output:

Tricolore FLTK


Perl, 90, 50 + 2 (-p flag) = 52 bytes 44 + 2 (-p flag) = 46 bytes

As nobody's done a Perl version yet, here we go:

$=sprintf "%c[44m%27s%c[47m%27s%c[41m%27s%c[40m\n",27,' ',27,' ',27,' ',27;print $ x 26;

$x=' ' x 27;$_="^[[44m$x^[[47m$x^[[41m$x^[[40m\n" x 26

$x=' 'x26;$_="^[[44m$x^[[47m$x^[[41m$x^[[0m\n"x26


00000000: 2478 3d27 2027 7832 363b 245f 3d22 1b5b  $x=' 'x26;$_=".[
00000010: 3434 6d24 781b 5b34 376d 2478 1b5b 3431  44m$x.[47m$x.[41
00000020: 6d24 781b 5b30 6d5c 6e22 7832 360a       m$x.[0m\n"x26.

enter image description here

  • \$\begingroup\$ You don't need the spaces around the x operator. Also, I suggest using 26 instead of 27, since some people still use 80-column terminals. \$\endgroup\$ – Neil Nov 22 '15 at 23:44
  • \$\begingroup\$ [0m works better for me since it resets my background to black whereas [40m gives me a very dark sky colour. And it also saves you an extra byte. \$\endgroup\$ – Neil Nov 22 '15 at 23:52

Python 2, 46 bytes


There is a non-printable ESC character at the beginning of the format string:

$ hexdump -C f.py 
00000000  73 3d 22 1b 5b 33 25 73  3b 31 6d 22 2b 22 23 22  |s=".[3%s;1m"+"#"|
00000010  2a 32 36 3b 70 72 69 6e  74 28 73 25 34 2b 73 25  |*26;print(s%4+s%|
00000020  37 2b 73 25 31 2b 22 5c  6e 22 29 2a 33 30        |7+s%1+"\n")*30|

Coloured space character version:

s="[3%s;7m"+" "*26;print(s%4+s%7+s%1+"\n")*30

Tiny version, 44 bytes

Doesn't fit for the "at least 78 chars wide" requirements.

s="[3%s;7m"+" "*9;print(s%4+s%7+s%1+"\n")*9

CJam, 43


Outputs an image in PPM format. Try it online


C#, 176 bytes as a Program

A program that outputs the Full Block character 219, 78 wide, 52 tall. If your font is square, this will have the correct ratio.

using System;class P{static void Main(){for(int x,y=52;y-->0;)for(x=4;x-->1;Console.Write(new string('█',26)+(x<2?"\n":"")))Console.ForegroundColor=(ConsoleColor)(x%3*3+9);}}

Indentation and new lines for clarity:

using System;
class P{
    static void Main(){
        for(int x,y=52;y-->0;)
            for(x=4;x-->1;Console.Write(new string('█',26)+(x<2?"\n":"")))

C#, 157 bytes as a Function

I argue that the requirements did not require a program and that a function would suffice. In that case, I can drop the byte count substantially.

using System;void F(){for(int x,y=52;y-->0;)for(x=4;x-->1;Console.Write(new string('█',26)+(x<2?"\n":"")))Console.ForegroundColor=(ConsoleColor)(x%3*3+9);}

Indentation and new lines for clarity:

using System;
void F(){
    for(int x,y=52;y-->0;)
        for(x=4;x-->1;Console.Write(new string('█',26)+(x<2?"\n":"")))
  • \$\begingroup\$ Nice logic, but it doesn't compile (even after correcting the parameters to your string constructor). You need to add a class, and static void Main, leaving you with 177 bytes. \$\endgroup\$ – Berend Nov 24 '15 at 14:04
  • \$\begingroup\$ @Berend, there was no requirement to have a full program. Even so, I'll add that option. And whoops on me for stuffing up the string! \$\endgroup\$ – Hand-E-Food Nov 24 '15 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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