Draw the national flag of France

105

14

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.

Leaderboard

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>

steve

Posted 2015-11-17T22:17:21.980

Reputation: 2 276

4Those RGB values don't match your image. From what I see, you've got RGB: (0, 35, 149), (255, 255, 255), (237, 41, 57). – beaker – 2015-11-18T00:18:53.933

8Storing 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? – JohnE – 2015-11-18T00:19:06.243

15Each 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. – Ben Jackson – 2015-11-18T00:19:47.597

34echo not quite big enough – Digital Trauma – 2015-11-18T04:08:03.310

How many lines are required with the ANSI text option? – dan04 – 2015-11-18T07:08:56.810

Since most browser consoles don't support ansi escape codes for coloring but do allow styling with %c and matching css declarations is that permitted? As in: http://codegolf.stackexchange.com/a/64159/11182

– George Reith – 2015-11-18T12:20:19.563

Is a Windows batch file accepted? I mean to say a .cmd or .bat file. I'm new to this site, I don't know if that counts as a language. – ghosts_in_the_code – 2015-11-18T16:20:29.280

@ghosts_in_the_code Yes, Windows batch is an acceptable language here. There are plenty of answers in it around the site. – Alex A. – 2015-11-18T16:53:07.660

5@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. – a spaghetto – 2015-11-18T22:26:40.053

3

Is the use of these emojis allowed ⚪️, as per this answer?

– Digital Trauma – 2015-11-18T22:39:57.203

@BenJackson with your suggestions my css example would perform better than the regular version of the flag :) – Fabrizio Calderan – 2015-11-23T09:02:48.480

@Steve, for java, do import statements count against the byte total? My imports alone are 62 bytes lol. – Ashwin Gupta – 2016-04-21T23:10:07.497

1Finally, I found this page again. – neverMind9 – 2018-12-09T22:26:43.943

Answers

38

CJam, 23 22 bytes

00000000: 27 9b 22 5c 22 25 1f 22 66 7b 69 27 6d 32 37 2a  '."\"%."f{i'm27*
00000010: 7d 4e 5d 32 36 2a                                }N]26*

The above is a hexdump that can be reversed with xxd -r.

At the cost of two extra bytes – for a total of 24 bytes – we can use background colors instead, making the output a bit prettier.

00000000: 27 9b 22 2c 2f 29 00 22 66 7b 69 27 6d 53 32 36  '.",/)."f{i'mS26
00000010: 2a 7d 57 4e 74 32 36 2a                          *}WNt26*

How it works

In both programs, we use the ANSI escape sequence \x9bXYm – where X is 3 for foreground color and 4 for background color, and Y specifies the color to use – to switch between the three colors of the flag.

'<CSI>       Push the '\x9b' character (Control Sequence Introducer).
"\"%<US>"    Push the string of the ISO 8859-1 characters with code
             points 34, 37, and 31.
f{           For each character in the string, push the CSI and that
             character; then:
  i            Cast the character to integer.
  'm27*        Push 27 m's. The first completes the control sequence,
               the remaining 26 will be printed.
}
N]           Wrap the generated array and "\n" in an array.
26*          Repeat it 26 times.

The other program is similar.

Output

output

Dennis

Posted 2015-11-17T22:17:21.980

Reputation: 196 637

I'm currently unsure how tall I should make the "image". – Dennis – 2015-11-18T00:14:20.927

I went with 78x30 in my answer. Those dimensions in Lucida Console 9 pt (the default font for xterm) gave the closest to 3:2. – Mego – 2015-11-18T01:21:50.773

You could use a full block for 'prettyness' – Matthew Roh – 2017-03-18T05:36:37.660

75

Pure Bash (on OSX), 84

The default OSX terminal supports full colour emojis. Not sure if this counts as text or graphical output.

printf -vs %26s
for i in {1..26}
do echo ${s// /}${s// /⚪️}${s// /}
done

Output looks like:

enter image description here


Alternatively:

Bash with OSX utilities, 56

yes `dc -e3do26^d1-dn2/*p|tr 201 ⚪️`|sed 26q

The dc expression:

  • calculates 3^26-1 and prints it in ternary 22222222222222222222222222
  • divides this by 2, then multiplies by 3^26. Output in ternary this is 1111111111111111111111111100000000000000000000000000

tr then translates the 210 characters to ⚪️. yes outputs this line indefinitely. sed 26q halts output at 26 lines.

Digital Trauma

Posted 2015-11-17T22:17:21.980

Reputation: 64 644

51A terminal that supports emojis. Wow. – rr- – 2015-11-18T19:09:17.707

6The first solution doesn't use the right RGB values nor does it use the standard ANSI colors, does it? – Doorknob – 2015-11-18T22:10:53.420

@Doorknob You're right of course - neither solutions do - so this answer may be overstepping the line. I've asked the OP for clarification

– Digital Trauma – 2015-11-18T22:41:04.690

3It's just Unicode. – undergroundmonorail – 2015-11-19T10:58:42.937

For me it doesn't even look like the france flag. It looks more kinda grey. – Zaibis – 2015-11-19T13:20:23.180

A slightly more compact version: printf -vs %26s;yes ${s// /}${s// /⚪️}${s// /}|head -26 – Daniel – 2015-11-19T19:21:50.650

@Daniel 67 bytes > 56 bytes. Or am I measuring it wrong? – Digital Trauma – 2015-11-19T20:42:50.463

1

@steve I wasn't really expecting this answer to become so popular, especially given that there are questions regarding its validity. Can you give a yay or nay as to whether you think it is valid? Thanks!

– Digital Trauma – 2015-11-20T21:15:45.280

How do you do byte counting? When I paste your answers at http://www.lettercount.com, I get much smaller byte counts (even though it counts emojis as 2 characters, which I think is correct.)

– geokavel – 2015-11-21T22:24:02.180

@DigitalTrauma I was looking at the 84 byte one. The second one is better than mine, yes.. – Daniel – 2015-11-22T22:30:54.743

@geokavel I usually just start wc, paste in the script and hit ^D. But you can also use this online counter. lettercount.com is counting characters and not bytes. The and are 4 bytes each and the ⚪️ is 6 bytes.

– Digital Trauma – 2015-11-28T21:52:27.280

Hm, I've seen unicode characters counted as 1 byte before. It seems unfair to make them count as so many bytes. – geokavel – 2015-11-28T21:56:41.410

@geokavel Its not unfair. UTF-8 encodes the 128 ASCII characters as one byte each, but others (non-ASCII) are encoded in anything from 2 to 6 bytes.

– Digital Trauma – 2015-11-28T22:00:53.170

Would UTF-16 help? – ev3commander – 2015-12-18T20:25:59.950

@ev3commander No, I don't think so - each character in the whole script would end up taking up 2 bytes, which would certainly significantly increase the score. UTF-8 is best for this because it encodes almost all of what we need in just one byte per char, with just the funny dots taking up more. – Digital Trauma – 2015-12-18T20:29:30.470

Oh. I thought that since Funciton programs (using lots and lots of Unicode) are encoded with UTF-16 to get lower byte counts, this would too. – ev3commander – 2015-12-18T20:30:41.623

@ev3commander For the record I just tried it - iconv -t UTF-16 fr.sh | wc -c gives 98 bytes. I'm not familiar with funciton, but with a brief look over its esolangs page I would guess it would encode better in CP437 which gives most of those characters in a single byte – Digital Trauma – 2015-12-18T20:40:58.407

51

Python 2, 47 bytes

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

Contains unprintables - here's a hexdump (reversible with xxd -r):

00000000: 733d 221b 5b33 2573 3b31 6d46 223b 7072  s=".[3%s;1mF";pr
00000010: 696e 7428 7325 342a 3236 2b73 2537 2a32  int(s%4*26+s%7*2
00000020: 362b 7325 312a 3236 2b22 5c6e 2229 2a33  6+s%1*26+"\n")*3
00000030: 30                                       0

Uses ANSI escape codes to print colored characters to STDOUT - I chose "F" for France. No online link because ideone doesn't support ANSI escape codes in output.

Thanks to Dennis and xnor for some great tips.

Screenshot from xterm:

flag

Mego

Posted 2015-11-17T22:17:21.980

Reputation: 32 998

1You've got an extra space there. in [0] --> in[0] – mbomb007 – 2015-11-17T22:34:27.740

2>

  • You can use actual ESC bytes instead of \x1b. 2. Bolding doesn't seem to be necessary. 3. I'm not sure if that applies to ANSI art as well, but the question seems to mandate a 3 : 2 ratio.
  • < – Dennis – 2015-11-17T23:00:13.493

    It's shorter to sub in the parameters with formatting: print("\x1b[3%s;1mF"*78+"\n")%((4,)*26+(7,)*26+(1,)*26)*30. – xnor – 2015-11-17T23:03:23.513

    Or better: s="\x1b[3%s;1mF";print(s%4*26+s%7*26+s%1*26+"\n")*30. – xnor – 2015-11-17T23:08:49.020

    16Press F to pay respects – Riking – 2015-11-18T08:14:29.363

    Are you sure that the first 's' should be in the code block? I can't see it, and it doesn't seem to work with it (but I haven't tested it it, I'm on my phone) – Loovjo – 2015-11-18T09:26:03.247

    @Loovjo Thanks for pointing that out, it was the result of a failure to copy and paste correctly :) – Mego – 2015-11-18T09:39:40.567

    4The character looks slightly nicer, e.g. print("\x1b[3%s;1m█"*78+"\n")%((4,)*26+(7,)*26+(1,)*26)*30 – ali_m – 2015-11-21T20:03:05.097

    51

    Desmos, 30 12 bytes

    3x>10
    3x<-10
    

    Try it online.

    I'm not entirely sure if this is valid, please let me know if there are any issues.

    a spaghetto

    Posted 2015-11-17T22:17:21.980

    Reputation: 10 647

    Don't forget to mentiond setting the colours. – Conor O'Brien – 2015-11-18T03:18:00.423

    3@CᴏɴᴏʀO'Bʀɪᴇɴ Default colors are red and blue in that order (I believe) so there is no need to set them. – a spaghetto – 2015-11-18T03:18:37.680

    You could just do x<-1\nx>1 and tell the people to zoom in :P And they are not the default colours; they are randomly chosen afaik – Conor O'Brien – 2015-11-18T03:22:48.897

    7@CᴏɴᴏʀO'Bʀɪᴇɴ Then it's a random flag generator ;) – DanTheMan – 2015-11-18T03:29:49.660

    3@CᴏɴᴏʀO'Bʀɪᴇɴ They're not random for me - inputting two inequalities manually is consistently getting me red, then blue. – Mego – 2015-11-18T03:34:34.300

    @Mego I got blue then green :P – Conor O'Brien – 2015-11-18T03:41:22.470

    1This is strange. I'm getting red and blue as well. – lirtosiast – 2015-11-18T04:44:12.340

    @CᴏɴᴏʀO'Bʀɪᴇɴ I didnt get that x<-1\nx>1. Could you please explain it? What is n here? – Kartik – 2015-11-18T12:59:42.193

    @Kartik \n is a newline. – Conor O'Brien – 2015-11-18T15:08:50.200

    are those the right blue and red? – njzk2 – 2015-11-18T18:59:18.587

    2I don't think it is... nor does it fit the aspect ratio precisely. – Doorknob – 2015-11-18T22:11:16.710

    The aspect ratio is fine (at least for me) but the colors are not right. – a spaghetto – 2015-11-18T22:15:35.570

    The colours were right for me as well as the ratio – Blue – 2015-11-18T22:54:39.440

    @muddyfish the colors need to be exactly (0, 85, 164), (255, 255, 255), (239, 65, 53). – a spaghetto – 2015-11-18T23:47:10.370

    44

    HTML / SVG, 76 bytes 87 88 121 122 149

    Saved 27 bytes thanks to @insertusernamehere

    Saves 9 bytes thanks to @Joey

    Saved 1 bytes thanks to @sanchies

    Saves 1 bytes thanks to @Neil

    <svg><path fill=#0055a4 d=m0,0h26v52H0 /><path fill=#ef4135 d=M52,0h26v52H52
    

    Using lots of HTML syntax abuse, this can get pretty short.


    Screenshot of output:

    France Flag Output


    Or try it (make sure your browser supports SVG):

    <svg><path fill=#0055a4 d=m0,0h26v52H0 /><path fill=#ef4135 d=M52,0h26v52H52

    Downgoat

    Posted 2015-11-17T22:17:21.980

    Reputation: 27 116

    3I tried to beat you with CSS and now I have golfed your SVG that it is even smaller than my CSS solution. :D This is the shortest I could get to work in Safari, Chrome and Firefox, it's 122 bytes long: <svg><rect width=78 height=52 fill="#ef4135"/><rect width=52 height=52 fill="#fff"/><rect width=26 height=52 fill=#0055a4> – insertusernamehere – 2015-11-18T00:45:28.767

    1@insertusernamehere Thanks, That saved 27 bytes! I've managed to further golf this down to an astonishing 88 bytes – Downgoat – 2015-11-18T01:12:10.043

    I think the second to last rule only applies to text output, because console output can only be basic colors. – geokavel – 2015-11-18T02:48:19.203

    @geokavel oh gotcha, I'll rollback – Downgoat – 2015-11-18T02:49:43.137

    It may just be me but your flag is upside down :S – Spaceman – 2015-11-18T03:50:51.727

    @Spaceman whoops, fixed – Downgoat – 2015-11-18T04:30:15.967

    3For me, fill=#0055a4 /> works too (no "), saving a whole byte. – Sanchises – 2015-11-18T10:30:42.213

    PHP to produce this svg (69 bytes): <svg<?=$x='><rect width=26 height=52 fill='?>"#0055a4"/<?=$x?>#ef4135 (may be golfed even further) – Ismael Miguel – 2015-11-18T15:06:58.000

    1It was upside down, now it's upside down and backwards! – undergroundmonorail – 2015-11-19T15:31:40.743

    3@sanchises a whole byte? o_O wow :D – developerbmw – 2015-11-21T05:47:19.313

    4@developerbmw Actually, it would be more impressive to save half a byte when you think about it. – Sanchises – 2015-11-21T08:48:34.807

    1@sanchises true, true. We need a programming language that only uses characters with values 0xF and below and the source can be compressed to use half-bytes :) – developerbmw – 2015-11-22T02:45:59.963

    This fails when the context it's shown in has a non-white background. I don't think the SVG spec mandates renderers to assume a white background. – Anko – 2015-11-22T23:18:49.743

    1@Anko HTML defaults to a white background. This isn't really an SVG file, more of just SVG in HTML, otherwise the syntax would be invalid. A language is defined by it's implementation so I'd say it's fine – Downgoat – 2015-11-23T00:25:16.793

    If we stick with not showing the white part, then I got it down to 79, rendering correctly in IE, Chrome, and FF: <svg><path fill=#0055a4 d=m0,0h26v52H0 /><path fill=#ef4135 d=M52,0h26v52H52/>. No one in their right mind should use rect when golfing SVG. – Joey – 2015-11-26T07:38:12.467

    For me with Firefox I was able to remove the second / character for another byte saved. – Neil – 2015-11-26T22:09:13.383

    29

    Brainfuck$, 153 bytes

    +++++++++++++[->>>++>+++++++>++++>>>>++++++++>+++<<<<<<<<<<]>>>+>>#->$#>$#+++++++>$--->+++++[<]<<+++++[->+++++>++++++<<]>+#>($#([-]>[.>]<[<])>>>>+++<<<<)
    

    Outputs the image with ANSI color codes. I chose a height of 30 like Mego.

    The reference implementation from 2009 linked on the esolangs page has gone missing. You can run it using this interpreter made by me, which supports everything from the esolangs page.

    window.addEventListener("load",function(){document.querySelector("#r").addEventListener("click",function(){var  c=document.querySelector("#c").value,u=document.querySelector("#i").value,d=Array(30000).fill(0),p=0,i=0,q=0,s=[],o=document.querySelector("#o");o.value="";eval(c.replace(/[^]/g,function(e,i){return{"+":"d[p]=(-~d[p]+256)%256;","-":"d[p]=(~-d[p]+256)%256;",">":"p++;","<":"p--;",",":"d[p]=q-u.length?u[q++].charCodeAt()%256:0;",".":"o.value+=String.fromCharCode(d[p]);","[":"while(d[p]){","]":"}","#":"s.push(d[p]);","$":"d[p]=s.pop();",";":"d[p]=(parseInt(prompt())%256+256)%256;",":":"o.value+=d[p].toString();","(":"for(var i"+i+"=d[p];i"+i+">0;i"+i+"--){",")":"}","@":"o.value+=('D '+d.slice(0,20)+'\\nS '+s+'\\nIP '+i+' DP '+p);"}[e]||"";}));});});
    <label for=c>Code:</label><br/><textarea style="width:100%;height:15em;white-space:pre" id=c>+++++++++++++[-&gt;&gt;&gt;++&gt;+++++++&gt;++++&gt;&gt;&gt;&gt;++++++++&gt;+++&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;]&gt;&gt;&gt;+&gt;&gt;#-&gt;$#&gt;$#+++++++&gt;$---&gt;+++++[&lt;]&lt;&lt; init sequence to cells 3 to 10&#10;+++++[-&gt;+++++&gt;++++++&lt;&lt;] set cells 1~2 to 25 &amp; 30&#10;&gt;+ set cell 1 to 26&#10;# push 26 to stack&#10;&gt; go to cell 2&#10;( do 30 times&#10;    $# get 26 to this cell from stack&#10;    ( do 26 times&#10;        [-]&gt;[.&gt;]&lt;[&lt;] print sequence&#10;    )&#10;    &gt;&gt;&gt;&gt;+++&lt;&lt;&lt;&lt; change color to white&#10;    $# get 26 to this cell from stack&#10;    ( do 26 times&#10;        [-]&gt;[.&gt;]&lt;[&lt;] print sequence&#10;    )&#10;    &gt;&gt;&gt;&gt;------&lt;&lt;&lt;&lt; change color to red&#10;    $# get 26 to this cell from stack&#10;    ( do 26 times&#10;        [-]&gt;[.&gt;]&lt;[&lt;] print sequence&#10;    )&#10;    &gt;&gt;&gt;&gt;+++&lt;&lt;&lt;&lt; change color to blue&#10;    ++++++++++. print newline&#10;)</textarea><br/><button id=r>Run</button><br/><label for=i>Input:</label><br/><textarea id=i style="width:100%"></textarea><br/><label for=o>Output:</label><br/><textarea readonly id=o style="width:100%;height:15em;white-space:pre"></textarea>

    Brainfuck, 258 bytes

    This is basically the same thing, but just in plain old Brainfuck.

    >>+++++++++++++[-<<++>>>>++>+++++++>++++>++++>+++++>++++>++++++++>+++[<]<]>>+>>->>------>--->+++++[<]<<<++++[>+++++[->+++++<]>+[>>[.>]<[<]<-]>>>>>+++[<]+++++[-<+++++>]<+[>>[.>]<[<]<-]>>>>>------[<]+++++[-<+++++>]<+[>>[.>]<[<]<-]>>>>>+++[<]<++++++++++.[-]<<-]
    

    Or, if you prefer this one in oOo CODE (984 bytes):

    one day ThERe WIlL Be PEaCE iN ThIS wORlD
    OnE DaY ThERe WiLl Be peaCe iN ThIS wOrld
    one day theRe WIlL be pEaCE iN ThIS wORlD
    OnE DaY theRe WIlL Be PEaCe in ThIS wORlD
    OnE day ThERe WIlL Be PEaCe in ThIS wORlD
    OnE day ThERe WIlL Be PEaCE iN ThIS wOrld
    OnE DaY ThErE wilL bE PeaCe IN this woRlD
    one day There will Be pEacE in ThiS woRld
    one Day TheRe will Be PEaCE iN ThIS wOrLd
    onE dAY thEre WilL Be PEaCE iN ThIs World
    OnE DaY ThERe WIlL bE pEace in ThIS wORlD
    OnE DaY thErE Will Be PeAce in this WoRLd
    one dAY thErE wilL bE PeaCE in tHIs world
    one day theRe WIlL Be PeAce iN tHIS wORlD
    OnE DaY ThErE wIll be PEaCE iN ThIS wORlD
    one dAY thERe WiLl be peace In THis worLD
    onE dAy thErE WilL Be peACe in this world
    one Day TheRe wIll Be pEace In thIs WORlD
    OnE DaY ThERe WiLl Be peaCE iN ThIS wORlD
    OnE day tHEre WIlL bE peace in tHiS World
    oNE daY tHere WiLL be PEace IN this world
    one day ThERe WIlL bE peaCe IN thIS wORlD
    OnE DaY ThERe WIlL Be PEaCE iN THis WoRld
    oNE daY thERe wiLL
    

    PurkkaKoodari

    Posted 2015-11-17T22:17:21.980

    Reputation: 16 699

    25

    Bash + ImageMagick, 60 77 73 bytes

    convert -sample 78x52\! - a<<<"P3 3 1 255 0 85 164 255 255 255 239 65 53"
    

    (ugh, +17 chars due to color requirements I didn't notice earlier...)

    Outputs to the file a, in netpbm format:

    llama@llama:~$ convert -sample 78x52\! - a<<<"P3 3 1 255 0 85 164 255 255 255 239 65 53"
    llama@llama:~$ file a
    a: Netpbm image data, size = 78 x 52, rawbits, pixmap
    

    Can also output in PNG, if you change the filename to a.png (+4 chars).

    Output:

    enter image description here

    Doorknob

    Posted 2015-11-17T22:17:21.980

    Reputation: 68 138

    1convert -sample 78x52\! - a<<<"P3 3 1 255 0 85 164 255 255 255 239 65 53" – Digital Trauma – 2015-11-17T23:50:05.660

    @DigitalTrauma Thanks! That saves 4 chars and doesn't exit with an error. (Also, I never knew ImageMagick could read from / write to STDIN.) – Doorknob – 2015-11-17T23:52:53.357

    You can use -scale instead of -sample; also, the backslash doesn't seem to be necessary – aditsu quit because SE is EVIL – 2015-11-25T06:41:35.293

    25

    LaTeX, 139 bytes

    Thanks to @WChargin for saving 21 bytes.

    \documentclass{proc}\input color\begin{document}\def\z#1!{{\color[rgb]{#1}\rule{4cm}{8cm}}}\z0,.33,.64!\z1,‌​1,1!\z.94,.25,.21!\end{document}
    

    This prints the following 12cm*8cm image on an A4 page:

    enter image description here

    Note that "Page 1" is also printed at the bottom of the page

    Fatalize

    Posted 2015-11-17T22:17:21.980

    Reputation: 32 976

    1Well this is about 100 bytes shorter than my asymptote solution... – Arcturus – 2015-11-18T13:09:07.463

    1s.\newcommand\z[1].\def\z#1 to save a bunch of bytes. Also, you can shave off a few by using \def\z#1!{…}\z0,.33,.64!\z1,1,1!\z.94,.25,.21!—that is, use your own delimiters instead of braces for grouping – wchargin – 2015-11-20T21:54:11.597

    1You can also \input color – wchargin – 2015-11-20T21:54:54.683

    1For completeness, revised version (139 bytes): \documentclass{proc}\input color\begin{document}\def\z#1!{{\color[rgb]{#1}\rule{4cm}{8cm}}}\z0,.33,.64!\z1,1,1!\z.94,.25,.21!\end{document} – wchargin – 2015-11-20T21:55:12.167

    24

    Pyth, 27 bytes

     .w*52[smmdGc3CM"\0U¤ÿÿÿïA5
    

    There are some unprintable chars, so here's a hexdump:

    00000000   2E 77 2A 35  32 5B 73 6D  6D 64 47 63  33 43 4D 22  .w*52[smmdGc3CM"
    00000010   5C 30 55 A4  FF FF FF EF  41 35                     \0U.....A5
    

    This creates a file o.png, which is exactly 78 pixels wide and 52 pixels tall:

    enter image description here

    Explanation:

    .w*52[smmdGc3CM"........
                   "........  a string containing the bytes 
                              0, 85, 164, 255, 255, 255, 239, 65, 53
                 CM           convert them to integers
               c3             split into 3 lists
          smmdG               duplicate each list 26 times
         [                    put them into a list
      *52                     and duplicate it 52 times
    .w                        save it as an image o.png
    

    Jakube

    Posted 2015-11-17T22:17:21.980

    Reputation: 21 462

    1For a second, I thought I had grossly misunderstood the PNG specification. – primo – 2015-11-18T20:11:43.067

    1save it as an image o.png, but there's no ".png" anywhere? – rev – 2015-11-22T20:25:41.927

    1@AsidShout How do you call the program? If you use python3 pyth.py code.pyth, then you can find it in the same directory. – Jakube – 2015-11-22T20:44:34.563

    21

    HTML (quirks mode), 68 bytes

    This uses quirks mode to render the flag.

    The HTML is VERY invalid, but works on a stock Android 4.4.2 browser and on Firefox 42.0 (on Windows 7 x64).

    <table width=78 height=52><td bgcolor=0055a4><td><td bgcolor=ef4135>

    The flag is rendered with the right size and the standard red and blue colors. All webpages start with a standard white background.



    As an alternative:

    A perfectly valid HTML5 version (141 bytes):

    <!DOCTYPE html><title>x</title><table style=width:78px;height:52px><tr><td style=background:#0055a4><td><td style=background:#ef4135></table>

    Check it's validity on: https://html5.validator.nu/

    Print-screen of the result:

    validation result

    Ismael Miguel

    Posted 2015-11-17T22:17:21.980

    Reputation: 6 797

    1Are you sure? When I have a HTML file with only this line, it doesn't work in Firefox, Chrome and Safari. If the file contains other HTML-elements after that line, it works for me. So maybe you can't discard the trailing >? – insertusernamehere – 2015-11-18T23:02:13.220

    1"Perfectly valid"? It should be style="..." if that's what you're going for in the second example. – mbomb007 – 2015-11-18T23:21:21.533

    3@mbomb007 What I am going for is to create the smallest valid HTML code. It validates with the official validator, so, it is perfectly valid HTML. You can try it yourself if you don't believe. – Ismael Miguel – 2015-11-19T01:25:41.240

    1@mbomb007 Also, missing quotes is the smallest issue: there's no <html>, no <head>, no <body>, no </tr>, no </td> and no closing of all missing tags. – Ismael Miguel – 2015-11-19T01:33:00.493

    1@insertusernamehere You were right. It was bugging on Android too. I tested it on jsfiddle. But when accessing data:text/html,<table width=78 height=52><td bgcolor=0055a4><td><td bgcolor=ef4135>, it wasn't working. Fixed it now, and use the link to test it. – Ismael Miguel – 2015-11-19T01:49:50.603

    17

    TI-Basic, 52 44 42 bytes

    GridOff
    AxesOff
    11
    Shade(-Ans,Ans,Xmin,Xmin/3
    Shade(-Ans,Ans,Xmax/3,Xmax,1,1,Ans
    

    (assumes a default [-10,10,1] by [-10,10,1] graph area)

    Would be 4 bytes shorter without the first 2 lines, but by default would have axes and would not look as nice.

    Looks like this:

    enter image description here

    If the shading is invalid for the challenge, let me know!

    Without the first 2 lines, it looks like this:

    enter image description here

    DanTheMan

    Posted 2015-11-17T22:17:21.980

    Reputation: 3 140

    I would also include the version without the first three lines just as a comparison. – GamrCorps – 2015-11-18T03:08:49.140

    1I think you can just go from Ymin to Ymax. You can also assume a default screen from -10 to 10. I'm also not sure about the validity of this, since the red and blue regions are only half shaded. – lirtosiast – 2015-11-18T03:21:46.597

    @ThomasKwa I edited my post to show why I didn't use just Ymin and Ymax. I didn't realize I could assume a default screen, but you aren't clear about what that default screen is. Could you please clarify? About the "half-shaded" thing, that is just how TI-Basic shades things, if it is invalid, I will promptly change it. – DanTheMan – 2015-11-18T04:06:21.123

    1A default screen is Ymin=Xmin=-10, Ymax=Xmax=10. The calculator starts with those window settings, and AxesOn etc, so you can assume them. – lirtosiast – 2015-11-18T04:42:48.000

    This doesn't use the right RGB values, does it? – Doorknob – 2015-11-18T22:12:00.293

    1@Doorknob As far as I know, it's impossible to do that without resorting to witchcraft. – DanTheMan – 2015-11-18T22:34:33.820

    @Doorknob I can verify that. The color tokens represent fixed colors; to change those nothing short of assembly will work. – lirtosiast – 2015-11-18T22:48:53.730

    RED isn't any shorter than 11. Both are 2 bytes. You can also golf by 2 bytes by using 11:Shade(-Ans,Ans,Xmin,Xmin/3:Shade(-Ans,Ans,Xmax/3,Xmax,1,1,Ans. – lirtosiast – 2015-11-18T22:50:18.610

    @ThomasKwa RED is more pretentious though. ;) Thanks for the tips though! – DanTheMan – 2015-11-18T22:52:40.437

    17

    ffmpeg, 110 113 116 117 119 108 100 bytes

    Display, using ffplay, 100 bytes:

    ffplay -f lavfi color=#0055a4:49x98[r];color=white:49x98[w];color=#ef4135:49x98[b];[r][w][b]hstack=3
    

    Saved to file, using ffmpeg, 108 bytes:

    ffmpeg -lavfi color=#0055a4:49x98[r];color=white:49x98[w];color=#ef4135:49x98[b];[r][w][b]hstack=3 -t 1 .png
    

    The current version of the command will abort with an error BUT will output a single image ".png", same as shown below.

    enter image description here

    Gyan

    Posted 2015-11-17T22:17:21.980

    Reputation: 521

    8Wow. Abusing ffmpeg to make images... – Cole Johnson – 2015-11-20T06:15:26.363

    Heh, I saw this question and thought of doing the same. Nice job making it compact. If it is allowed you can make it slightly smaller by using white instead of #ffffff: the values should be the same. – llogan – 2015-11-20T19:11:20.913

    I know. Wasn't bothered enough. Will do it now. – Gyan – 2015-11-20T19:22:00.867

    Does #fff work? – ev3commander – 2015-11-20T20:24:36.173

    No. But I can skip the f in f.png – Gyan – 2015-11-20T20:29:29.923

    Where exactly is the output? I don't see a flag anywhere, but I do get -bash: [r][w][b]hstack=3: command not found. – numbermaniac – 2017-04-23T01:32:18.610

    A file .png is created i.e. Name is blank and extension is PNG. Works here on Win7. – Gyan – 2017-04-23T04:42:30.707

    16

    JavaScript, 140 143 147 151 153 bytes

       with(document)with(body.appendChild(createElement`canvas`).getContext`2d`)for(i=2;i--;fillRect(i*52,0,26,52))fillStyle=i?"#ef4135":"#0055a4"

    Edits

    • Saved 2 bytes by replacing 2*i*26 with i*52. Thanks to Cᴏɴᴏʀ O'Bʀɪᴇɴ.
    • Saved 4 bytes by refactoring the for-loop. Thanks to ETHproductions.
    • Saved 2 bytes by using the with-statement. Thanks to Dendrobium.
    • Saved 2 bytes by turning increment into decrement. Thanks to Shaun H.
    • Saved 3 bytes by replacing fillStyle=["#0055a4","#ef4135"][i] with i?"#ef4135":"#0055a4".

    insertusernamehere

    Posted 2015-11-17T22:17:21.980

    Reputation: 4 551

    32*i*26 can become 52*i, no? – Conor O'Brien – 2015-11-18T00:01:27.210

    7@CᴏɴᴏʀO'Bʀɪᴇɴ Of course it can. Thanks. It's way beyond my bed time. – insertusernamehere – 2015-11-18T00:06:59.257

    By simply rearranging the for loop, you can cut 4 bytes: for(i=0;i<2;x.fillRect(i++*52,0,26,52))x.fillStyle=["#0055a4","#ef4135"][i] – ETHproductions – 2015-11-18T00:57:38.333

    @ETHproductions Thanks a lot, I've updated the answer. – insertusernamehere – 2015-11-18T10:00:35.760

    2You can shave off 2 bytes by using the with statement: with(document)with(body.appendChild(createElement\canvas`).getContext`2d`)for(i=0;i<2;fillRect(i++*52,0,26,52))fillStyle=["#0055a4","#ef4135"][i]` – Dendrobium – 2015-11-18T17:14:27.217

    2save a byte:

    x=(d=document).body.appendChild(d.createElementcanvas).getContext2d;for(i=3;--i;x.fillRect(i*52,0,26,52))x.fillStyle=[,"#ef4135","#0055a4"][i] – Shaun H – 2015-11-18T22:37:48.543

    2@Dendrobium That's good. Thanks a lot. – insertusernamehere – 2015-11-18T22:49:06.123

    @ShaunH I had to write it a bit different, but it saved another 2 bytes. Thanks a lot. – insertusernamehere – 2015-11-18T22:49:47.077

    16

    CSS, 127 128 144 bytes

    body:before,body:after{content:'';float:left;width:33%;height:100%;background:#0055a4}body:after{float:right;background:#ef4135}
    

    No need for another tag, works solely with the body-element.

    Edits

    • Saved 16 bytes by removing display:block; and some ;.
    • Saved 1 byte, removed the trailing }.

    insertusernamehere

    Posted 2015-11-17T22:17:21.980

    Reputation: 4 551

    6Though technically CSS isn't a programming language by our definitions. – Conor O'Brien – 2015-11-18T00:04:54.440

    10

    @CᴏɴᴏʀO'Bʀɪᴇɴ I know – just wanted to beat SVG.

    – insertusernamehere – 2015-11-18T00:08:32.540

    4@CᴏɴᴏʀO'Bʀɪᴇɴ is right, this is not a valid answer. – Mego – 2015-11-18T02:45:27.470

    This is no longer beating the SVG answer. – Riking – 2015-11-18T08:18:40.727

    @Riking I know, after I posted this answer I outplayed myself by golfing the SVG answer to a lower byte count. :) – insertusernamehere – 2015-11-18T09:02:30.960

    @CᴏɴᴏʀO'Bʀɪᴇɴ What exactly are the definitions? – Random832 – 2015-11-18T17:38:57.463

    @Random832 These, mon amis, are the definitions.

    – Conor O'Brien – 2015-11-18T19:00:02.440

    @CᴏɴᴏʀO'Bʀɪᴇɴ Well, if that includes HTML+CSS, this is just the combination of the given CSS file with the empty HTML document. – Random832 – 2015-11-18T21:32:41.780

    @Random832 HTML isn't a programming language alone by our standards. – Conor O'Brien – 2015-11-18T22:04:26.797

    @CᴏɴᴏʀO'Bʀɪᴇɴ Then you're going to have to make it a bit more clear what you meant by this link, because it links to a question, and the highest voted answer is Peter Taylor's, and he says in a comment on another answer that HTML+CSS qualifies. – Random832 – 2015-11-18T22:07:05.167

    @Random832 Don't be ticked. If you think it's okay, then roll with it. Only my opinion. – Conor O'Brien – 2015-11-18T22:08:53.663

    2@CᴏɴᴏʀO'Bʀɪᴇɴ it the css was saved as a SASS file, since SASS is a scripting language would it be a valid answer? – Fabrizio Calderan – 2015-11-20T17:37:47.450

    1@FabrizioCalderan So long as the program is valid, yeah. – Conor O'Brien – 2015-11-20T17:41:28.443

    6Yeah, regular CSS is a valid SASS file. – ev3commander – 2015-11-20T20:26:53.687

    13

    R, 59 bytes

    frame();rect(0:2/3,0,1:3/3,1,,,c("#0055a4",0,"#ef4135"),NA)
    

    Output is displayed:

    enter image description here

    One can also do 49 bytes with

    barplot(rep(1,3),,0,col=c("#0055a4",0,"#ef4135"))
    

    if you do not mind the axes and borders:

    enter image description here

    flodel

    Posted 2015-11-17T22:17:21.980

    Reputation: 2 345

    2The ratio seems wrong. I think you have a 2:3 to ratio on a single-colored rectangle instead of a 3:2ratio on the whole flag. – Fatalize – 2015-11-18T08:50:24.220

    The ratio can be adjusted manually by resizing the plotting window. – flodel – 2015-11-18T11:19:18.720

    3To qualify, your entry should work 'out of the box'. Else, anyone can post a 6-pixel solution and say 'You can manually zoom in'. – Sanchises – 2015-11-18T17:07:29.983

    4You say 'axes', I say 'flag pole'. – None – 2015-11-19T10:08:37.367

    2@sanchises: I'm French and I say f**k it. LIBERTE! – flodel – 2015-11-19T11:23:37.913

    @flodel I give you, f**k it, égalité! :) – Sanchises – 2015-11-19T11:30:10.423

    12

    Blitz 2D/3D, 154 108 bytes

    This produces exactly the same thing as the example given in the question (except for the anti-aliasing at the edges where colors meet).

    Graphics 800,533
    ClsColor 255,255,255
    Cls
    Color 0,35,149
    Rect 0,0,267,533
    Color 237,41,57
    Rect 533,0,267,533
    

    Output is displayed and it looks like this:

    enter image description here

    El'endia Starman

    Posted 2015-11-17T22:17:21.980

    Reputation: 14 504

    12

    Mathematica, 63 94 103 bytes

    When I first saw this challenge, I thought Sweet! Mathematica would be perfect for this! until I noticed that built-ins were banned :'(

    But wait! I can use bar graphs!

    r=RGBColor;BarChart[{1,1,1},ChartStyle->{r@"#0055a4",White,r@"#ef4135"},BarSpacing->0,AspectRatio->2/3]
    

    (Thanks to Martin Büttner for shaving off 5 bytes but adding 16)

    Looks like this:

    enter image description here

    If you add ,Axes->None it looks like this:

    enter image description here

    If you don't care about the border, you can use this: (95 bytes)

    r=RGBColor;BarChart[{1,1},ChartStyle->{r@"#0055a4",r@"#ef4135"},BarSpacing->1,AspectRatio->2/3,Axes->None]
    

    Looks like this:

    enter image description here

    Without axes:

    enter image description here

    DanTheMan

    Posted 2015-11-17T22:17:21.980

    Reputation: 3 140

    3Axes->None. You should also specifty AspectRatio->2/3. Renaming RGBColor is simple: r=RGBColor;...r["..."]. You can also use prefix-notation to save two more bytes r@"#0055a4". – Martin Ender – 2015-11-18T07:40:37.207

    If you don't need the outline, try BarChart[{1, 1}, ChartStyle -> {RGBColor["#0055a4"], Red}, BarSpacing -> 1]. The Red looks close enough. – DavidC – 2015-11-18T13:05:31.867

    @DavidCarraher Meh, since the question specifies a particular RGB value, that one should be used exactly. – Martin Ender – 2015-11-18T15:58:12.427

    My main recommendation was to draw two rectangles, not three. You are technically correct about Red, however. – DavidC – 2015-11-18T16:13:29.680

    Wouldn't the borders around the bars invalidate this solution? – LegionMammal978 – 2015-11-18T22:10:50.413

    11

    Javascript (ES6) 117 bytes

    Draws it in the console

    for(i=c=s=[];i<156;c[i++]=`color:${[,'blue','#fff'][i%3]||(s+=`
    `,'red')}`)s+='%c'+'+'.repeat(26);console.log(s,...c)

    George Reith

    Posted 2015-11-17T22:17:21.980

    Reputation: 2 424

    2For 'white' I think it's shorter to do: #fff. Also, the Red and Blue colors must match the colors specified in the spec – Downgoat – 2015-11-18T02:10:29.980

    1You can save a few bytes with i=c=s=[] instead of i=0,c=[],s='' after updating the colours that might help a little... – Dom Hastings – 2015-11-18T08:32:57.390

    1@Vɪʜᴀɴ When outputting in text, you can use the standard colors (red and blue). It's the 2nd point, counting from the bottom. This is within the spec. – Ismael Miguel – 2015-11-18T16:29:28.933

    @DomHastings Nice tip, clever use of coercion. Thanks! – George Reith – 2015-11-18T16:58:32.247

    @Vɪʜᴀɴ Thanks for the tip, I think the colours are valid because like Ismael said I am using text output. The browser consoles I've tried don't support actual ANSI codes but I've asked for clarification on that. – George Reith – 2015-11-18T17:00:03.777

    On Chrome, this comes out at least 2 to 3 times taller than it should be for the 2:3 ratio (I think, at least) – cat – 2015-11-18T18:01:14.357

    1@sysreq Its text in the console... I have no control over your console's lineheight. It's 78 characters wide 52 tall. – George Reith – 2015-11-18T18:46:02.427

    This doesn't use the right RGB values nor does it use the standard ANSI colors, does it? – Doorknob – 2015-11-18T22:12:42.960

    @Doorknob I was under the impression that ANSI has a standardisation of the color names and not the RGB values. That is platform/application independent. – George Reith – 2015-11-18T22:55:54.530

    @Doorknob It uses the color red (#F00), white (#FFF) and blue (#00F). If you check the link provided by the O.P., you will notice that those colors are in the "light" line. So, yes, those are valid. – Ismael Miguel – 2015-11-19T02:24:39.890

    @IsmaelMiguel The question specifies the RGB values that must be used. – Doorknob – 2015-11-19T02:30:56.457

    @Doorknob I suggest that you read the 2nd point counting from the bottom. It talks about textual output. The colors are fine. Read it and move along. Nothing invalid here. – Ismael Miguel – 2015-11-19T08:41:16.147

    @IsmaelMiguel This answer does not fall under the category "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.)" It a.) doesn't use ANSI color codes and b.) doesn't use standard blue, white, and red. Therefore, it has to use the RGB values specified. – Doorknob – 2015-11-19T12:22:43.153

    @Doorknob It outputs text to a console, using the defined colors. If you wish, ping me on the chat. This discussion is getting pointless pretty quicly. I gave my upvote and I will keep it. – Ismael Miguel – 2015-11-19T13:31:53.817

    10

    pb, 68 bytes

    cw[Y!52]{cccw[X!26]{b[77]>}ccccw[X!52]{b[77]>}cw[X!78]{b[77]>}<[X]v}
    

    Wow, a challenge that pb is actually kinda good for! Those are few and far between.

    When I was writing the spec for pb, I included coloured output mostly as a joke. The language was named after a "paintbrush", why would it not do colour? Other than example programs, this is the second time I've ever used it. It is implemented with ANSI codes as the question requires.

    I used 'M' as the character to output with because it's fairly dense.

    Output:

    I resized that screenshot vertically to be two thirds of its height because letters aren't square. The output is 78 by 52, but the original screenshot looks really wrong.

    With comments and indentation and junk:

    c               # Increase output colour by 1
                    # 0 (White) -> 1 (Red)
                    # Loop ends with output colour == 1, this is cheaper than
                    # setting it back to white every time.
    
    w[Y!52]{        # While the brush's Y coordinate is not 52:
        ccc           # Increase output colour by 3
                        # 1 (Red) -> 4 (Blue)
    
        w[X!26]{      # While the brush's X coordinate is not 26:
            b[77]       # Write 'M' at the brush's coordinates
            >           # Increase X coordinate by 1
        }             
    
        cccc          # Increase output colour by 4
                        # 4 (Blue) -> 8 mod 8 = 0 (White)
    
        w[X!52]{      # While the brush's X coordinate is not 52:
            b[77]       # (same as before)
            >         
        }             
    
        c             # Increase output colour by 1
                        # 0 (White) -> 1 (Red)
    
        w[X!78]{      # While the brush's X coordinate is not 78:
            b[77]       # (same as before)
            >
        }
    
        <[X]          # Set X back to 0
        v             # Increase Y by 1
    }
    

    undergroundmonorail

    Posted 2015-11-17T22:17:21.980

    Reputation: 5 897

    78x30 will get you the dimensions you want for terminal output. – Mego – 2015-11-18T07:14:06.690

    @Mego Yeah, but I'm not sure if it's allowed. – undergroundmonorail – 2015-11-18T07:15:21.530

    The resulting output on xterm in the default font matches the specified dimensions. – Mego – 2015-11-18T07:17:23.237

    I'd feel weird measuring the size of console output in anything but "characters", though. – undergroundmonorail – 2015-11-18T07:28:22.900

    1When your characters are 1.2x as tall as they are wide, they don't make for very good pixels. – Mego – 2015-11-18T09:40:59.513

    10

    C, 115 bytes

    enter image description here

    #define c"[48;2;%d;%d;%dm%9c"
    d=255;main(a){while(a++<9)printf(c c c c,0,85,164,0,d,d,d,0,239,65,53,0,0,0,0,10);}
    

    Contains unprintables:

    00000000: 2364 6566 696e 6520 6322 1b5b 3438 3b32  #define c".[48;2
    00000010: 3b25 643b 2564 3b25 646d 2539 6322 0a64  ;%d;%d;%dm%9c".d
    00000020: 3d32 3535 3b6d 6169 6e28 6129 7b77 6869  =255;main(a){whi
    00000030: 6c65 2861 2b2b 3c39 2970 7269 6e74 6628  le(a++<9)printf(
    00000040: 6320 6320 6320 632c 302c 3835 2c31 3634  c c c c,0,85,164
    00000050: 2c30 2c64 2c64 2c64 2c30 2c32 3339 2c36  ,0,d,d,d,0,239,6
    00000060: 352c 3533 2c30 2c30 2c30 2c30 2c31 3029  5,53,0,0,0,0,10)
    00000070: 3b7d 0a                                  ;}.
    

    For this program to work, a couple of things need to be true:

    • The terminal supports the ESC [48;2;<r>;<g>;<b>m "truecolor" escape sequence.
    • The terminal is not xterm, becase xterm's implementation of the above will produce slightly wrong colors.
    • The terminal completely ignores NUL characters.

    It also looks nicer if your terminal's background is black.

    To change to height of the flag, pass command line arguments to the program. For every argument passed, the flag becomes one line shorter. It's not a bug, it's a feature!

    Output:

    enter image description here

    Functino

    Posted 2015-11-17T22:17:21.980

    Reputation: 417

    Had trouble compiling this with gcc (version 5.1.1). Any specific flags needed to compile? "a.c:1:10: warning: ISO C99 requires whitespace after the macro name #define c"\x1b[48;2;%d;%d;%dm" – steve – 2015-11-20T14:03:11.077

    1@Steve is that a warning our an error? – Functino – 2015-11-20T16:55:02.047

    1@Steve Just tested it again, gcc 5.2.1. No flags. Produced 12 warnings but made a working binary. – Functino – 2015-11-20T17:07:42.030

    apologies - works fine - got confused by the warnings (and the fact that the code looks pretty cryptic to a C newbie like me) – steve – 2015-11-20T19:32:01.003

    9

    MATLAB, 82 79 78 bytes

    x=[0 1 1 0];y(3:4)=2;fill(x,y,[0 85 164]/255,x+1,y,'w',x+2,y,[239 65 53]/255)
    

    Output looks like:

    costrom

    Posted 2015-11-17T22:17:21.980

    Reputation: 478

    1Which version of MATLAB? Doesn't work on r2013a as colours need to be decimal numbers in the range [0,1]. – Tom Carpenter – 2015-11-18T00:35:27.977

    1The following line works fill(x,y,[0 85 164]/255,x+1,y,'w',x+2,y,[239 65 53]/255) and saves you 2 bytes. :) I'd also use semi-colons instead of newlines to avoid extra stuff being printed out. – Tom Carpenter – 2015-11-18T00:39:05.313

    1@TomCarpenter I spaced on the 0-1 color scale, it's been a little while since I've had to specify colors. As for the semicolons/newlines, I was choosing readability over console writing, but I've changed my answer – costrom – 2015-11-18T01:22:11.020

    9

    CSS, 102 110 111 114 bytes

    *{background:linear-gradient(90deg,#0055a4 33%,#fff 33%,#fff 66%,#ef4135 66%) 0 0/78px 52px no-repeat

    Thomas Eschemann

    Posted 2015-11-17T22:17:21.980

    Reputation: 191

    1* *{background:linear-gradient(90deg,#0055a4,#0055a4 33%,#fff 33%,#fff 66%,#ef4135 66%) 0 0/78px 52px no-repeat} - one byte shorter – user2428118 – 2015-11-18T13:59:03.190

    1actually a single * is enough :) Thanks! – Thomas Eschemann – 2015-11-18T14:08:12.247

    1+1; You could save another byte by removing the trailing }. – insertusernamehere – 2015-11-18T22:57:48.053

    1You can delete the first color, you save 8 bytes. – Awashi – 2015-11-25T08:28:02.130

    You can replace last 66% with 0. – Mr_Green – 2016-11-10T09:08:24.183

    9

    Visual Basic+Excel, 618 137 bytes

    Just curious to see how this can be golfed.

    EDIT: Curiosity sated, thanks to @Neil and @JimmyJazzx, 618 bytes dropped right down to 137 bytes

    Sub a(): Columns("A:C").ColumnWidth = 26: Range("A1:A13").Interior.Color = RGB(0, 85, 164): Range("C1:C13").Interior.Color = RGB(239, 65, 53): End Sub
    

    Excel flag

    steve

    Posted 2015-11-17T22:17:21.980

    Reputation: 2 276

    1Recording a macro results in terribly inefficient code. Try Range("A1:C13").Interior.ColorIndex = 5 and Range("G1:I13").Interior.ColorIndex = 3 which seems to suffice. – Neil – 2015-11-22T23:29:27.780

    2Sorry, that was Excel 2003, and I forgot to include the ActiveWorkbook.Colors to specify the exact RGB values. Excel 2007 has additional colour options but I don't know them offhand. – Neil – 2015-11-22T23:36:48.150

    1I get 137 bytes with a few Quick Changes. I think you can Cut this down more but this is the easy changes. Sub a():Columns("A:C").ColumnWidth=26:Range("A1:A13").Interior.Color=RGB(0,85,164):Range("C1:C13").Interior.Color=RGB(239,65,53):End Sub – JimmyJazzx – 2015-11-23T20:32:15.827

    I get 135 with Sub a:Columns("A:C").ColumnWidth=26:Range("A1:A13").Interior.Color=RGB(0,85,164):Range("C1:C13").Interior.Color=RGB(239,65,53):End Sub – Joey – 2015-11-26T07:44:55.480

    8

    iKe, 43 bytes

    ,(0 0;"|"\"#0055A4|#FFF|#EF4135";52#,&3#26)
    

    This is an example of a "raw tuple" iKe program- it's just a description of an origin (0 0), a palette (3 7#"#0055A4#FFFFFF#EF4135") and a bitmap (+52#'&3#26). You need to wrap a description like this in a function or use references to views if you want to animate it.

    The palette is a very simple way of creating a series of CSS colors, hex equivalents of the spec.

      3 7#"#0055A4#FFFFFF#EF4135"
    ("#0055A4"
     "#FFFFFF"
     "#EF4135")
    

    If the color requirements were less stringent we could use one of iKe's built-in palettes and save a considerable number of characters:

    windows@7 0 4
    

    flag

    Try it in your browser.

    Edit:

    Saved one byte by using a short #FFF CSS color for the white stripe:

    ,(0 0;3 7#"#0055A4#FFFFFF#EF4135";+52#'&3#26)
    ,(0 0;"|"\"#0055A4|#FFF|#EF4135";+52#'&3#26)
    

    If anyone else is interested in playing with iKe, there's a manual on the github repo. here's another problem I solved using iKe.

    Edit 2:

    Saved one byte with a simpler way to construct the bitmap:

    +52#'&3#26
    52#,&3#26
    

    My question in the OP hasn't been answered, but for the record if more flexible color requirements are permitted, this program would be 30 bytes by using the Windows 3.1 palette:

    ,(0 0;windows@7 0 4;52#,&3#26)
    

    flag2

    Since this problem was posted, iKe has gained a feature which automatically centers textures drawn without a position, which could save another 3 bytes, but this would be against the rules:

    ,(;windows@7 0 4;52#,&3#26)
    

    JohnE

    Posted 2015-11-17T22:17:21.980

    Reputation: 4 632

    8

    Dyalog APL (47 44)

    ⎕SM←↑1 21 41{(''⍴⍨2/20)1⍺,⍵,⍨4↑0}¨2*8 11 10
    

    Result:

    flag

    marinus

    Posted 2015-11-17T22:17:21.980

    Reputation: 30 224

    2can you do 2*8 11 10? – lirtosiast – 2015-11-18T02:26:12.110

    1@ThomasKwa: thanks – marinus – 2015-11-18T02:48:26.287

    7

    Octave, 77 76 bytes

    s(98,49)=0;imshow(cat(3,[s w=s+255 w-18],[s+35 w s+41],[s+149 w s+57])/255);
    

    Displays the image:

    enter image description here

    beaker

    Posted 2015-11-17T22:17:21.980

    Reputation: 2 349

    7

    Processing, 100 Bytes

    size(78,52);background(255);noStroke();fill(#0055A4);rect(0,0,26,52);fill(#EF4135);rect(52,0,26,52);
    

    Displays this: France

    (The naive solution is shorter than my first one.)

    geokavel

    Posted 2015-11-17T22:17:21.980

    Reputation: 6 352

    I think Processing's drawing commands can come out ahead of pixel pushing here: size(78,52);noStroke();int[]p={0xFF0055A4,255,0xFFEF4135};for(int c:p){translate(26,0);fill(c);rect(0,0,-26,52);} – JohnE – 2015-11-18T00:59:26.013

    @JohnE Lol, yeah i just noticed that. – geokavel – 2015-11-18T00:59:46.527

    @JohnE Even my super basic solution is shorter than yours! – geokavel – 2015-11-18T01:00:51.713

    haha- looks like we both overcomplicated it – JohnE – 2015-11-18T01:01:12.427

    how about abusing the scale instructions? This works on sketchpad.cc but might break in Processing 3: size(78,52);scale(26,52);fill(#EF4135);stroke(#0055A4);rect(0,-1,0,2);stroke(255);rect(1,-1,3,3); – JohnE – 2015-11-18T03:00:15.840

    @JohnE It doesn't work when I paste it into Processing, because there seem to be some unprintable characters. I don't really understand what you're doing though. Why are you using stroke()? – geokavel – 2015-11-18T03:16:56.460

    By scaling up the canvas I shorten the constants necessary to draw 26x52 rectangles, but also the stroke (which is on by default) will be 26 pixels wide. Thus, instead of drawing a background I can draw two stripes by using the edge of one rectangle. The solution doesn't depend on any unprintable characters, so if there's an issue with that it's just stackoverflow screwing it up. – JohnE – 2015-11-18T03:20:32.110

    background(-1) is one byte shorter than background(255) – user41805 – 2017-04-23T15:36:12.960

    7

    PHP, 70 bytes

    0000000: 424d 0000 0000 0000 0000 2300 0000 0c00  BM........#.....
    0000010: 0000 2001 c000 0100 0800 a455 00ff ffff  .. ........U....
    0000020: 3541 ef3c 3f66 6f72 283b 3665 343e 2469  5A.<?for(;6e4>$i
    0000030: 3b29 6563 686f 2063 6872 2824 692b 2b2f  ;)echo chr($i++/
    0000040: 3936 2533 293b                           96%3);
    

    The above is a hexdump which may be reversed with xxd -r. Alternatively, it may also be generated with the following PHP script:

    <?=hex2bin('424d0000000000000000230000000c0000002001c00001000800a45500ffffff3541ef3c3f666f72283b3665343e24693b296563686f206368722824692b2b2f39362533293b');
    

    I assume default settings, as they are without an .ini (you may disable your local .ini with the -n option). Produces a .bmp image (288 x 192), which should be piped to a file. This is as large as I can make it without affecting the byte count.


    Sample Usage

    $ xxd -r in.hex > france.php
    $ php -n france.php > out.bmp
    $ out.bmp
    

    Output

    French Flag

    primo

    Posted 2015-11-17T22:17:21.980

    Reputation: 30 891

    These colors don't look right. Do they use the RGB values specified in the question? – Doorknob – 2015-11-18T22:17:10.633

    @Doorknob They do. Starting at byte 26, a three value color palette is defined (bgr): A45500, FFFFFF, 3541EF. – primo – 2015-11-19T00:42:37.143

    7

    Ruby, 56 47 45 bytes

    ASCII

    $><<"\e[34z\e[37z\e[31z\n".gsub(?z,?m*27)*52
    

    Peter Lenkefi

    Posted 2015-11-17T22:17:21.980

    Reputation: 1 577

    Yep, this is better than mine. Except the middle bar needs to be white. – Reinstate Monica -- notmaynard – 2015-11-18T21:27:16.723

    @iamnotmaynard True, fixed. Thanks! – Peter Lenkefi – 2015-11-18T21:35:11.063

    6

    ShaderToy (GLSL), 147 bytes

    void mainImage(out vec4 o,vec2 i){float x=i.x/iResolution.x*3.0;vec3 w=vec3(255,255,255);o=vec4((x<1.0?vec3(0,85,164):x<2.0?w:vec3(239,65,53))/w,1);}
    

    See it here

    Not particularly exciting. I'm sure there are ways to golf it more; I'll take a crack when I get home.

    Robert Fraser

    Posted 2015-11-17T22:17:21.980

    Reputation: 912

    3

    The link redirects to https://www.shadertoy.com/error :/

    – Quentin – 2015-11-19T00:38:17.860

    6

    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}
    

    Output:

    powershell_france

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

    Jeff

    Posted 2015-11-17T22:17:21.980

    Reputation: 161

    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

    – Cole Johnson – 2015-11-20T06:13:58.507

    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} – steve – 2015-11-24T23:10:44.430

    Save 5 more by replacing ForegroundColor with the shorter Foreground. – steve – 2015-11-24T23:21:18.980

    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} – steve – 2015-11-24T23:28:29.287

    Wow! I learn more doing code golf than writing code lol. – Jeff – 2015-11-25T23:46:37.640

    2How about @("█"*26)*30|%{sal w write-host;w $_ -f 9 -n;w $_ -n;w $_ -f 4} at 63 bytes – TessellatingHeckler – 2015-12-18T23:58:17.640

    6

    Googly Blockly, 45 blocks

    Blockly source code

    Produces

    Blockly output

    Try it here

    Bassdrop Cumberwubwubwub

    Posted 2015-11-17T22:17:21.980

    Reputation: 5 707

    6

    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

    Explanation:

    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).

    Radovan Garabík

    Posted 2015-11-17T22:17:21.980

    Reputation: 437

    Any chance of a link to an emulator/interpreter? – Mego – 2015-11-21T12:45:47.670

    2Presumably 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 – Neil – 2015-11-22T23:20:58.360

    5

    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                                             |..|
    00000022
    

    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
    
    start:
        ; 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
    newrow:
        ; === 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
    span:
        ; === 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
        ret
    

    Matteo Italia

    Posted 2015-11-17T22:17:21.980

    Reputation: 3 669

    It's backwards. And I don't think the color are right. – lirtosiast – 2015-11-24T01:34:49.467

    @ThomasKwa: sorry, order fixed; the colors are what the nearest that are available in the default VGA palette. – Matteo Italia – 2015-11-24T01:36:37.823

    4

    Marbelous, 122 bytes

    @0
    --34
    =0Ro
    \/@0
    :Ro
    }0
    ..1B'['0'm0A
    Bl1B'['4'1'm
    Bl1B'['4'7'm
    Bl1B'['4'4'm
    {0
    :Bl
    @0
    --1A
    =0PS
    &0@0
    }0
    &0
    {0
    :PS
    }0
    {0'F
    

    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.

    Sparr

    Posted 2015-11-17T22:17:21.980

    Reputation: 5 758

    4

    Unix Shell, 57 bytes.

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

    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.

    Random832

    Posted 2015-11-17T22:17:21.980

    Reputation: 796

    Can you share an xxd dump or base64 decode of this? – Digital Trauma – 2015-11-18T16:25:58.987

    @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. – Random832 – 2015-11-18T16:59:21.073

    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. – Digital Trauma – 2015-11-18T18:52:02.633

    @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. – Random832 – 2015-11-18T18:54:20.510

    This doesn't use the correct RGB values, does it? – Doorknob – 2015-11-18T22:17:32.207

    @Doorknob It uses the ANSI color option... I'd overlooked the non-whitespace requirement (and still don't understand the purpose of it). – Random832 – 2015-11-18T22:20:19.920

    Ah, yes, sorry, misread the question (didn't see the "standard ANSI colors" part). – Doorknob – 2015-11-18T22:21:11.440

    4

    Befunge-98, 170 bytes

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

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

    PurkkaKoodari

    Posted 2015-11-17T22:17:21.980

    Reputation: 16 699

    4

    CBM BASIC 7.0, 76 bytes

    1fOi=1to26:?"r←";:goS3:?"e";:goS3:?"£";:goS3:?:nE:end
    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

    Psychonaut

    Posted 2015-11-17T22:17:21.980

    Reputation: 233

    4

    Javascript, 91 bytes

    Not the most exciting one.

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

    console.log((Z='%c▮')+Z+Z,(X='font-size:100px;color:#')+'0055a4','color:#fff',X+'ef4135')

    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:

    Printscreen



    As an alternative, with 84 bytes:

    console.log((Z='%c█')+Z+Z,(X='font-size:9cm;color:#')+'0055a4',X+'fff',X+'ef4135')

    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:

    Printscreen

    Ismael Miguel

    Posted 2015-11-17T22:17:21.980

    Reputation: 6 797

    4

    QBASIC, 88 122 Bytes

    SCREEN 13
    h=200
    a=100
    PALETTE 2,856123
    PALETTE 1,2626816
    LINE(0,0)-(a,h),1,BF
    LINE(a,0)-(h,h),15,BF
    LINE(h,0)-(300,h),2,BF
    

    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

    Jens

    Posted 2015-11-17T22:17:21.980

    Reputation: 191

    You could make the image slightly smaller (e.g. 96x64) to save a few bytes. The colors aren't quite right, though. – primo – 2015-11-19T23:37:54.943

    1@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. – Jens – 2015-11-20T01:45:36.600

    4

    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 :)

    http://codepen.io/anon/pen/xweEBX?editors=010

    *{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.

    http://codepen.io/anon/pen/BoEXZP?editors=010

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

    Result

    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}
    

    Fabrizio Calderan

    Posted 2015-11-17T22:17:21.980

    Reputation: 470

    To save yet another byte, you can remove the last }. Also, using 66.6% may produce the same result. – Ismael Miguel – 2015-12-01T09:38:04.293

    4

    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

    URL-encoded:

    data:text/html,%3Cstyle%3Ebody%7Bborder-left%3A2cm%20solid%20%230055a4%3Bwidth%3A2cm%3Bheight%3A4cm%3Bborder-right%3A2cm%20solid%20%23ef4135

    Ismael Miguel

    Posted 2015-11-17T22:17:21.980

    Reputation: 6 797

    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

    – Matheus Avellar – 2017-08-13T02:32:04.410

    4

    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.

    6infinity8

    Posted 2015-11-17T22:17:21.980

    Reputation: 371

    1Feel free to revert if you want; I removed your character count because this question is scored by bytes. – lirtosiast – 2015-11-24T01:40:40.150

    4

    ZX Spectrum Z80 assembly, 32, 30 Bytes

        org 8000h  
    
    red:      equ 16   
    white:    equ 120  
    blue:     equ 8  
    
    
    
    start:
        ld    c,16     ;height
        ld    e,8      ; blue/offset/counter
        ld    hl,5800h
    sheldon:
        ld    b,e      ;counter
    fun:
        ld    (hl),e   ;blue
        inc   hl
        djnz  fun
        ld    b,e      ;counter
    with:
        ld   (hl),white
        inc  hl
        djnz with
        ld   b,e       ;counter
    flags:
        ld   (hl),red
        inc  hl
        djnz flags
        ld   d,b       ;e holds offset       
        add  hl,de
        dec  c
        jr   nz,sheldon
        ret
    
        end
    
        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

    Z80 coder

    Posted 2015-11-17T22:17:21.980

    Reputation: 51

    3

    LibreLogo, 88 85 bytes

    Code:

    pc [24]lt 90 fd 26 fc 21924 rectangle[52,26]rt 180 fd 52 fc 0xef4135 rectangle[52,26]
    

    Result:

    enter image description here

    Explanation:

    pc [24]                     ; Pen Color = INVISIBLE
    lt 90                       ; Left 90°
    fd 26                       ; Forward 26 pt
    fc 21924                    ; Fill Color = RGB(0, 85, 164)
    rectangle [52, 26]          ; Rectangle 52x26 pt
    rt 180                      ; Right 180°
    fd 52                       ; Forward 52 pt
    fc 0xef4135                 ; Fill Color = RGB(239, 65, 53)
    rectangle [52, 26]          ; Rectangle 52x26 pt
    

    Previous Attempts:

    pc [24]lt 90 fd 26 fc 0x0055a4 rectangle[52,26]rt 180 fd 52 fc 0xef4135 rectangle[52,26]
    

    Grant Miller

    Posted 2015-11-17T22:17:21.980

    Reputation: 706

    3

    Excel VBA 62 bytes

    VBE Immediate Window commands

    [a1:d25].interior.colorindex=23:[i1:l25].interior.colorindex=3
    

    French Flag

    Stupid_Intern

    Posted 2015-11-17T22:17:21.980

    Reputation: 373

    This is not quite correct - your colors a a bit off. You can correct them for +2 bytes with [A1:D25].Interior.Color=&HA45500:[I1:L25].Interior.Color=3490286 – Taylor Scott – 2017-08-12T14:56:04.723

    3

    Mathematica, 131 bytes

    ".png"~Export~ImageCrop@Graphics[{RGBColor@"#0055a4",{0,0}~Rectangle~{1,2},RGBColor@"#ef4135",{2,0}~Rectangle~{3,2}},ImageSize->82]
    

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

    LegionMammal978

    Posted 2015-11-17T22:17:21.980

    Reputation: 15 731

    2Does Mathematica not have some sort of country flags built-in? – Skyler – 2015-11-18T14:33:34.330

    @Skyler "Built-in flag images/libraries are not allowed." Besides, Mma's flag uses a different blue color. – LegionMammal978 – 2015-11-18T22:09:33.647

    3

    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)
    lt(180)
    fillcolor("#0055a4")
    D()
    fillcolor("white")
    goto(100,0)
    D()
    fillcolor("#ef4135")
    goto(200,0)
    D()
    

    Try it here

    TanMath

    Posted 2015-11-17T22:17:21.980

    Reputation: 1 431

    2Put 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. – Mego – 2015-11-18T05:06:31.407

    3This also doesn't work. – Mego – 2015-11-18T05:08:32.827

    You can remove the space between import and * – undergroundmonorail – 2015-11-18T13:24:15.340

    @Mego now it does. – TanMath – 2015-11-18T19:12:58.243

    @undergroundmonorail it ha already been removed. – TanMath – 2015-11-18T19:13:11.570

    3

    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

    eval("console.log(('%cFRANCE'.repeat(3)+'\\n').repeat(6)"+",'color:#0055A4','color:#FFF','color:#EF4135'".repeat(6)+")")
    

    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

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

    Moved var decs into for loop saved 5 bytes :D

    Try it out here :).

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

    Spaceman

    Posted 2015-11-17T22:17:21.980

    Reputation: 251

    3

    PostScript, 128 bytes.

    %!PS
    <</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
    
    %!PS
    /a{setrgbcolor rectfill}def
    0 0 26 52 0 .33 .64
    52 0 26 52 .94 .25 .21<</PageSize[78 52]>>setpagedevice
    a a
    

    Random832

    Posted 2015-11-17T22:17:21.980

    Reputation: 796

    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. – firefrorefiddle – 2015-11-18T15:21:55.050

    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. – Random832 – 2015-11-18T15:23:30.400

    3

    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)))
    

    Jacob

    Posted 2015-11-17T22:17:21.980

    Reputation: 1 582

    3

    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);
    

    Sanchises

    Posted 2015-11-17T22:17:21.980

    Reputation: 8 530

    3

    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.

    Reinstate Monica -- notmaynard

    Posted 2015-11-17T22:17:21.980

    Reputation: 1 053

    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. – Doorknob – 2015-11-19T01:37:16.157

    3

    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();}}
    

    drjenkin

    Posted 2015-11-17T22:17:21.980

    Reputation: 31

    Welcome to PPCG! You can shave off a lot of bytes by removing essentially all the whitespace in your program (newlines, spaces, and tabs) - only the spaces in static void Main are necessary. – Mego – 2015-11-19T15:58:24.080

    Cheers Mego. Great to be here :) – drjenkin – 2015-11-19T16:40:08.677

    2You'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. – Mego – 2015-11-19T16:45:36.857

    You can also remove the namespace, it's not mandatory – IEatBagels – 2015-11-19T17:31:45.157

    2Remember, 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. – Sanchises – 2015-11-19T19:45:52.440

    3The 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. – Tom van der Zanden – 2015-11-20T09:16:00.290

    1Assign 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. – ChicagoRedSox – 2015-11-21T06:58:36.573

    1Some 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! – Berend – 2015-11-24T13:51:37.233

    3

    Ruby with Shoes, 119 bytes

    Shoes.app(width:78,height:52){strokewidth 0
    [rgb(0,85,164),white,rgb(239,65,53)].map{|c|
    fill c
    rect$.,0,26,52
    $.+=26}}
    

    Sample output:

    French Tricolour

    manatwork

    Posted 2015-11-17T22:17:21.980

    Reputation: 17 865

    3

    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

    Sanchises

    Posted 2015-11-17T22:17:21.980

    Reputation: 8 530

    3

    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
    

    Hexdump:

    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

    steve

    Posted 2015-11-17T22:17:21.980

    Reputation: 2 276

    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. – Neil – 2015-11-22T23:44:29.037

    [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. – Neil – 2015-11-22T23:52:22.233

    3

    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}}}
    

    Ungolfed:

    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

    manatwork

    Posted 2015-11-17T22:17:21.980

    Reputation: 17 865

    3

    JavaScript 206 175

    c=c.getContext('2d')
    d=c.createImageData(w=78,h=52),a=Int32Array(d.data.buffer)
    for(i=w*h;i--;)a[i]=-[6007552,1,13286929][i%w/26|0]
    c.putImageData(d,0,0)
    <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];
      x.putImageData(d,0,0);
      g.src = c.toDataURL();
    }
    
    function allFrance() {
      var g = document.getElementsByTagName("img");
      for(var i = g.length; i--;) france(g[i]);
    }
    
    allFrance()
    

    wolfhammer

    Posted 2015-11-17T22:17:21.980

    Reputation: 1 219

    use c instead of document.getElementById('c'). Also remove the new keyword. – Mama Fun Roll – 2015-11-21T19:48:35.843

    Thansk @ןnɟuɐɯɹɐןoɯ it worked! – wolfhammer – 2015-11-21T21:24:22.120

    3

    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":"")))
                    Console.ForegroundColor=(ConsoleColor)(x%3*3+9);
        }
    }
    

    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":"")))
                Console.ForegroundColor=(ConsoleColor)(x%3*3+9);
    }
    

    Hand-E-Food

    Posted 2015-11-17T22:17:21.980

    Reputation: 7 912

    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. – Berend – 2015-11-24T14:04:34.300

    @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! – Hand-E-Food – 2015-11-24T22:04:42.050

    3

    Python 2, 46 bytes

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

    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|
    0000002e
    

    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
    

    Ray

    Posted 2015-11-17T22:17:21.980

    Reputation: 131

    3

    CJam, 43

    'P[Z"s<h8_.KUw'rFa"158b256b3/(\30f*60*]e_N*
    

    Outputs an image in PPM format. Try it online

    aditsu quit because SE is EVIL

    Posted 2015-11-17T22:17:21.980

    Reputation: 22 326

    3

    PowerShell, 152 bytes

    sal w write-host;$v=" "*26;foreach($u in 1..26){;w $v -backgroundcolor blue -NoNewLine;w $v -backgroundcolor white -NoNewLine;w $v -backgroundcolor red}
    

    enter image description here

    Richie Lee

    Posted 2015-11-17T22:17:21.980

    Reputation: 31

    Hi, welcome to golf. Be aware there's another powershell contribution, where comments have it down to 97 bytes. – steve – 2015-11-25T10:57:09.470

    If you were to apply some of the changes in that earlier 97 byte one (the changes are only in the comments and not incorporated into the posting itself) you'd end up with something like sal w write-host;$v=" "*26;1..26|%{w $v -background 1 -NoNewLine;w $v -background 6 -NoNewLine;w $v -background 12} taking yours down from 152 to 115. – steve – 2015-11-25T16:04:40.410

    2

    Je préfère (en /bin/bash):

    for i in {a..z}; do printf '\033[4%-28s' 4m 7m 1m; echo; done
    

    Inspirée d'une autre contribution, mais les caractères ne fonctionnaient pas trop (escape)

    Vive la République!

    Dan0

    Posted 2015-11-17T22:17:21.980

    Reputation: 121

    2Welcome to the site. This is a [tag:code-golf] competition so the objective is to make your source as small as possible, you could likely eliminate a good deal of the size here by removing whitespace. – Post Rock Garf Hunter – 2017-07-16T05:17:35.657

    2

    PaperScript, 83 bytes

    R=Path.Rectangle
    R(0,0,49,98).fillColor="#0055a4"
    R(98,0,49,98).fillColor="#ef4135"
    

    PaperScript is an extension of JavaScript based on the Paper.js vector graphics library. You can run PaperScript code directly, without having to mess with the HTML and CSS, at sketch.paperjs.org.

    This code is very straightforward: it draws a rectangle and colors it blue; then it draws another rectangle and colors it red. (The arguments to Path.Rectangle are x, y, width, and height, respectively.) The background is assumed to be white. Try it at Paper.js Sketch!

    Output

    Displayed at the top left of the canvas:

    Le drapeau de la France

    DLosc

    Posted 2015-11-17T22:17:21.980

    Reputation: 21 213

    2

    Java (JDK 10), 86 bytes

    v->{for(int i=0,x;i<4108;)System.out.printf((x=i++%79/26*3+4)<13?"[3%sm@":"\n",x%9);}
    

    Try it online!

    Notes:

    • On TIO, it will print the characters, not the flag. To show the flag, run it in Bash.
    • There is a \u001b character between " and [3%sm@.

    Credits:

    • steve for giving the idea of moving the i++to a more appropriate place, sparing one byte.

    Olivier Grégoire

    Posted 2015-11-17T22:17:21.980

    Reputation: 10 647

    Does java permit i++<4108 ? – steve – 2018-08-07T09:48:08.623

    @steve Yes, of course. But that would require some refactoring of the code to compute the appropriate value to print out. Gonna check that out. – Olivier Grégoire – 2018-08-07T09:49:14.503

    Figure you might save a byte in the for(). – steve – 2018-08-07T09:50:23.213

    @steve Thanks! I indeed saved a byte, but not where you thought. You sparked that idea, though! ;) – Olivier Grégoire – 2018-08-07T09:53:02.663

    2

    Lua + LÖVE, 176 174 bytes

    l=love
    g=l.graphics
    l.window.setMode(78,52)
    function l.draw()for k,v in next,{[0]={0,85,164},{255,255,255},{239,65,53}}do
    g.setColor(v)g.rectangle("fill",k*26,0,26,52)end
    end
    

    Sample output:

    Tricolore LÖVE

    manatwork

    Posted 2015-11-17T22:17:21.980

    Reputation: 17 865

    2

    JavaScript, 141 bytes

    a='';for(j=0;j<24;j++){for(i=1;i<80;i++){a+="<d style='color:"+(78/i<1.5?'blue':(78/i<3?'white':'red'))+"'>F</d>"}a+="<br>"}document.write(a)

    (click "full page" to see the proper result)

    nicael

    Posted 2015-11-17T22:17:21.980

    Reputation: 4 585

    1136 bytes: for(j=0,a='';j<24;j++,a+='<br>')for(i=1;i<80;i++)a+='<d style=color:'+(78/i<1.5?'blue':(78/i<3?'#fff':'red'))+'>F</d>';document.write(a) – Ismael Miguel – 2015-11-21T02:50:37.703

    @Ismael yey, great :) – nicael – 2015-11-22T11:12:57.320

    2

    ActionScript, 90 bytes

    var g=graphics,f=g.beginFill,d=g.drawRect;f(21924);d(0,0,26,52);f(0xef4135);d(52,0,26,52);

    Ouput:

    output

    Jimbo Jonny

    Posted 2015-11-17T22:17:21.980

    Reputation: 121

    2

    Processing, 88 bytes

    size(78,52);scale(26,52);stroke(-1);background(#EF4135);fill(#0055A4);rect(-2,-1,3.5,3);
    

    benja

    Posted 2015-11-17T22:17:21.980

    Reputation: 21

    Wow! Mind explaining how that works? – user41805 – 2016-12-02T18:15:32.590

    2

    FLIF, 37 bytes

    FLIF is an excellent bitmap format for when you really want to squeeze some bytes away:

    4c46 4649 3133 4e00 3400 1e27 2ce3 5d2f
    ab15 8fdd c110 4117 8d25 5fa2 c8b6 d02d
    fdfe af77 000a
    

    Using viewflif:

    France flag in application viewflif

    algmyr

    Posted 2015-11-17T22:17:21.980

    Reputation: 858

    FLIF is not a programming language

    – TuxCrafting – 2017-01-26T15:20:25.117

    @TùxCräftîñg Correct, but the task was: "Produce this flag in the fewest bytes possible". No mention of a programming language (ignoring the leaderboard part). Isn't codegolf often about bending/abusing the rules in your favor anyway? :) – algmyr – 2017-01-27T11:13:27.127

    Code golf is about abusing the language, not the rules :) – TuxCrafting – 2017-01-27T13:49:24.663

    1

    SmileBASIC, 55 bytes

    GCLS-1GFILL.,0,26,52,-16755292GFILL 52,0,78,52,-1097419
    

    12Me21

    Posted 2015-11-17T22:17:21.980

    Reputation: 6 110

    1

    Tcl/Tk, 81 80

    gri [can .c -bg #fff]
    .c cr r 0 0 26 52 -f #0055A4
    .c cr r 52 0 78 52 -f #EF4135
    

    enter image description here

    sergiol

    Posted 2015-11-17T22:17:21.980

    Reputation: 3 055

    1

    Processing, 128 bytes

    void setup(){size(90,60);fill(0,0,255);rect(0,0,30,60);fill(255);rect(30,0,60,60);fill(255,0,0);rect(60,0,90,60);}void draw(){}
    

    enter image description here

    Dat

    Posted 2015-11-17T22:17:21.980

    Reputation: 879

    You can do fill(-1) instead of fill(255) to save a byte – user41805 – 2017-04-23T15:11:31.663

    You can also remove the draw statement because it is not needed here – user41805 – 2017-04-23T15:11:58.290

    You can do background(255,0,0); to omit the fill(255,0,0);rect(60,0,90,60); – user41805 – 2017-04-23T15:13:03.567

    1

    Bash, 35 bytes

    echo -e "\033[44m \033[m \033[41m "
    

    enter image description here

    Khaled.K

    Posted 2015-11-17T22:17:21.980

    Reputation: 1 435

    1

    HTML, 124 bytes

    converted rob values mentioned in the question to the hex ones, that cuts off 13 bytes

    <a><b><c><style>*{position:fixed;left:0;right:0;bottom:0;top:0}a{background:#0055A4;width:33%}c{background:#EF4135;left:66%;

    Very invalid HTML. Unclosed and non-standard elements (fun fact: I can't remove the last semicolon, doesn't render). If your window isn't resized to the aspect ratio of 3:2, I'd advice you to do it ;)

    nicael

    Posted 2015-11-17T22:17:21.980

    Reputation: 4 585

    1Only text flags are supposed to use blue and red. Graphical outputs should use the exact colors mentioned in the question. – manatwork – 2015-11-22T12:23:07.180

    @man that's a pity, fixed. – nicael – 2015-11-22T13:41:43.723

    1

    Tandy Color Computer 2 BASIC, 131 bytes

    CLS:B$=CHR$(175):W$=CHR$(207):R$=CHR$(191):L$=B$+B$+B$+B$+B$+B$+W$+W$+W$+W$+W$+W$+R$+R$+R$+R$+R$+R$:?L$:?L$:?L$:?L$:?L$:?L$:?L$:?L$
    

    Ungolfed (somewhat):

    10 CLS
    20 B$=CHR$(175)
    30 W$=CHR$(207)
    40 R$=CHR$(191)
    50 L$=B$+B$+B$+B$+B$+B$+W$+W$+W$+W$+W$+W$+R$+R$+R$+R$+R$+R$
    60 ?L$:?L$:?L$:?L$:?L$:?L$:?L$:?L$
    

    I could save 4 bytes if I removed the clear screen code in the beginning (CLS) but it would like kinda gnarly seeing all the code listed on one line then the flag thereafter... otherwise, this clears the screen, assigns B$ the solid blue character, W$ the solid white character, and R$ the solid red character. Then creates a line (L$) with 6 each blue, white, red characters and writes 8 lines of that out to standard output.

    This takes advantage of the upper ASCII codes in the Motorola 6847 VDG (Video Display Generator) chip that the CoCo 1 & 2 relied on; they were block graphic codes in any of 8 colors.

    As the standard character size of the CoCo was 8 pixels wide by 12 pixels deep, the only way to get the correct ratio at the minimum size is to use 6 characters per color wide by 8 lines. 6*3*8=144 pixels wide, and 8*12=96 pixels deep. 144/96=1.5x wider than tall, or 3:2 ratio.

    This also takes advantage of the '?' character being shorthand for the PRINT statement. If you list the ungolfed version of the program you actually will see 8 instances of 'PRINTL$:' instead of '?L$:' due to the tokenization of the '?' being equal to 'PRINT'. However, to my knowledge you can't list a one-liner (a.k.a. 'immediate mode') BASIC program.

    zmerch

    Posted 2015-11-17T22:17:21.980

    Reputation: 541

    1

    Python 3, 54 51 bytes

    c="\033[0;4%sm ";print((c%4*30+c%7*30+c%1*30+"\n")*30)
    

    c="\033[0;4%sm"+" "*30;print((c%4+c%7+c%1+"\n")*30)
    

    Output: French flag in Python 3

    AmauryPi

    Posted 2015-11-17T22:17:21.980

    Reputation: 11

    I browsed the other answers and found a very similar Python2 one, beating me because of the parenthesis required in 3, and because a simple colored character is printed instead of a full background color. – AmauryPi – 2015-11-24T13:00:54.153

    Are the RGB values of the red, white, and blue up to specification? – GamrCorps – 2015-11-24T13:39:55.663

    I'm restricted to the terminal red, white and blue, but in modern terminals you can change these colors to match the specification. I did not mentioned this to focus on the implementation. – AmauryPi – 2015-11-24T16:10:27.423

    Reduced from 54 to 51 bytes by removing the duplicated *30. – AmauryPi – 2015-11-24T16:19:26.760

    1

    R, 57 bytes

    barplot(c(1,1),,c(1),yaxt='n',col=c("#0055a4","#ef4135"))
    

    enter image description here

    Abhijit

    Posted 2015-11-17T22:17:21.980

    Reputation: 2 841

    1

    C++ (Windows), 398 bytes

    #include <iostream>
    #include <Windows.h>
    using namespace std;int main(){HANDLE h=GetStdHandle(STD_OUTPUT_HANDLE);int c=0;for(int i=0;i<52;++i){while(c<78){if(c<26){SetConsoleTextAttribute(h,FOREGROUND_BLUE);cout<<"F";}else if(c<52){SetConsoleTextAttribute(h,FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED);cout<<"F";}else{SetConsoleTextAttribute(h,BACKGROUND_RED);cout<<" ";}++c;}c=0;cout<<endl;}}
    

    My first submission! It's quite long, partly because setting console colour in Windows is long, and partly because I have no idea what I'm doing!

    otah007

    Posted 2015-11-17T22:17:21.980

    Reputation: 111

    Using constants is good coding practice. But in code golf challenges we usually just use the given values literally and we pre-calculate values if that helps. For example FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED7. (At least according to CHAR_INFO structure. I have no Windows to try it.)

    – manatwork – 2015-11-25T14:52:56.523

    1

    Postscript, 136 bytes

    /r{rlineto}def /b{translate newpath 0 0 moveto 0 2 r 1 0 r 0 -2 r closepath setrgbcolor fill}def 90 90 scale 0 .33 .64 1 1 b 1 0 0 2 0 b
    

    enter image description here

    Spehro Pefhany

    Posted 2015-11-17T22:17:21.980

    Reputation: 111

    1

    ImageScript, 63 bytes (non-competing)

    rgb(0,85,164)rect(0,0,200,400)rgb(239,65,53)rect(400,0,200,400)

    MCMastery

    Posted 2015-11-17T22:17:21.980

    Reputation: 783

    Link is down. Is there another resource where I can experiment with this language? – Grant Miller – 2017-04-24T20:14:54.463

    1

    Python, 67 63 bytes

    Straightforward as PPM:

    print"P6 78 52 255 "+(26*"\x00U\xff"+78*"\xff"+26*"\xefA5")*52
    

    Usage:

    python golf_france.py > france.ppm
    

    Edit1: Binary PPM is shorter, haven't figured out how to use to strange codes directly in the strings.

    Karl Napf

    Posted 2015-11-17T22:17:21.980

    Reputation: 4 131

    1

    PostScript, 48 bytes

    Based on earlier (supposedly dodgy) postscript entry, optimized with a loop and 2-byte synonyms, also includes exact colours.

    Hex dump:

    00000000: 3020 2e33 3333 202e 3634 3388 0030 881a  0 .333 .643..0..
    00000010: 8834 2e39 3337 202e 3235 3520 2e32 3038  .4.937 .255 .208
    00000020: 8834 3088 1a88 3432 7b92 9d92 807d 9283  .40...42{....}..
    

    goose121

    Posted 2015-11-17T22:17:21.980

    Reputation: 151