Draw the national flag of Iceland

  • This year's UEFA Euro 2016 is over and besides a couple of negative headlines there has been a very positive surprise as well – the Iceland national football team. Let's draw their national flag.



    Input



    Well, obviously this challenge has no input.



    Output




    • Draw the flag of Iceland in any applicable visual format of at least 100 x 72 pixels or 25 x 18 characters.

    • Save the output to a file or present it instantly – example formats are: images like png, jpg etc., vector graphics, draw on HTML canvas or even use non-whitespace characters for visualization.

    • Use these colors: blue: #0048e0, white: #ffffff and red: #d72828.

    • If your language doesn't support specific color values, use the standard values for red, blue and white from the ANSI color codes.

    • Draw the flag with the correct proportions, as shown in the figure below:




    Boilerplate




    • You can write a program or a function. If it is an anonymous function, please include an example of how to invoke it.

    • This is so shortest answer in bytes wins.

    • Standard loopholes are disallowed.






    Leaderboard





    var QUESTION_ID = 85141; // Obtain this from the url
    // It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
    var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
    var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
    var OVERRIDE_USER = 41859; // This should be the user ID of the challenge author.
    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,]*[^\s,]),.*?(-?\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,});});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;if (! /<a/.test(lang)) lang = '<i>' + lang + '</i>';lang = jQuery(lang).text().toLowerCase();languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link, uniq: lang};});var langs = [];for (var lang in languages)if (languages.hasOwnProperty(lang))langs.push(languages[lang]);langs.sort(function (a, b) {if (a.uniq > b.uniq) return 1;if (a.uniq < b.uniq) 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);}}

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

    <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/Sites/codegolf/all.css?v=617d0685f6f3"><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><div id="language-list"><h2>Winners 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><table style="display: none"><tbody id="answer-template"><tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td><a href="{{LINK}}">{{SIZE}}</a></td></tr></tbody></table><table style="display: none"><tbody id="language-template"><tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td><a href="{{LINK}}">{{SIZE}}</a></td></tr></tbody></table>





    If you can't find your answer, format your language and byte count as explained in the Leaderboard's "Info Section".






    This challenge is inspired by Draw the national flag of france.


    Far more challenging would be the flag of my country, who also did a lot better than expected in the Euros this year - Wales. :-)

    @Gareth I'm looking forward to a waterproof specification of the dragon. ;)

    It looks like the blue in the above image is darker than the actual `#0048e0`

    @GiacomoGarabello Yes, it is.

    @LuisMendo Both, the approximately color values and the image are from Wikipedia, so they may differ slightly. The image is mainly to show the proportions. Please use the colors from the question as copied from this link.

    @MartinEnder Does carving it on a stone tablet count? That's waterproof.

    @MartinEnder Mathematica will have one.

    Are you sure you want one character to be one unit? 100x72 characters seems very big and there are answers below which actually have smaller flags. Could you please clarify?

    @insertusernamehere This is still inconsistent with Giacomo Garabello's answer, which you declared as valid.

    @Kritzefitz Ob boy, I see it now. I miscounted the lines - actually his answer misses 4 lines. Good catch. Will get in touch with him. Looking at so many similar answers and checking proportions can be confusing.

    Actually, outdated version of Leaderboard installed. But I see I'm the only annoyed by the lack of stylesheet.

    There is no official up to date version. You either edit the CSS path manually, or use the suggested version I posted in an answer, but which contains other changes too.

    Congratulations on your gold badge!

    @LuisMendo Thanks a lot. I'm still overwhelmed by the sheer amount of responses and people participating in this challenge, whether with own submissions or by helping others to improve their answers.

    Looks like victories for assembly languages, von Neumann would be proud

    Why are assembly program sizes listed below measured by the output of the assembler, not by the assembler source (10x larger)? Is this part of some FAQ? I.e. if my Java *.class file is smaller than my *.java source file, can I just hexdump the *.class file and claim the smaller byte count? I mean, if they painstakenly wrote their solutions in hex and then disassembled them for our convenience, that's one thing. But it looks like they wrote them in assembler so shouldn't that be what's measured?

  • Python 3, 190 172 171 169 167 160 159 147 143 bytes



    Using PIL version 1.1.7 which has a deprecated but not removed offset method.



    from PIL.ImageDraw import*
    i=Image.new('RGB',(25,18),'#d72828')
    Draw(i).rectangle((1,1,23,16),'#0048e0',~0)
    i.offset(9).resize((100,72)).show()


    Creates a 25*18 pixel image filled with red then draws a 23*16 pixel rectangle filled with blue with white outline of one pixel. It then offsets the image by (9,9) which wraps on the edges, resizes it to 100*72 then shows it in a window.



    Flag before offsetting:



    enter image description here (resized to 100*72)



    Output:



    enter image description here



    Animated:



    enter image description here



    Edit1: Golfed 18 bytes by removing the cropping by initially creating a 25*18 image.



    Edit2: Golfed 1 byte by using #fff instead of white.



    Edit3: Golfed 2 bytes by aliasing imports.



    Edit4: Golfed 2 bytes by removing the second argument of the offset method .



    Edit5: Golfed 7 bytes by showing the image instead of saving. (needs imagemagick installed on Unix)



    Edit6: Golfed 1 byte by rewriting imports.



    Edit7: Golfed 12 bytes by rewriting imports again. (thanks by @Dennis)



    Edit8: Added animation.



    Edit9: Updated animation as it was missing the last frame.



    Edit10: Golfed 4 bytes thanks to Albert Renshaw!


    Which PIL version? With 3.1.2 I get “Exception: offset() has been removed. Please call ImageChops.offset() instead.”

    I'm using Pillow version 2.3.0 which has PIL version 1.1.7. The offset method has been moved to the ImageChops module in PIL 1.2.

    Oh. Sorry, not familiar with Python graphics in general. Pillow 3.1.2's PIL 1.1.7 is the one that give the error: http://pastebin.com/nBXaw8Xe Well, probably depends on the build options used by the package maintainers (I'm on Ubuntu Xenial).

    Really nice answer.

    Excellent solution. I was trying to think of a block-matrix type approach in Mathematica, but this is much better. The similar solution in MMA amounts to 110 bytes: `Image[RotateRight[a[Table[2,56,84],4,1]~(a=ArrayPad)~4/.{2->8{0,9,28}, 1->255{1,1,1},0->5{43,8,8}},4{9,9}]/255]`

    This is genius! (Viking)Hat off to you.

    Wow, it's rare that I vote on code-golf type questions on SO, but it's even rarer that I'll join a whole new community just to do so. This offset hack is reminiscent of what we used to have to do before you young whippersnappers got your oodlebytes of memory to work with. Excellent job.

    genius,really!

    I think it may be possible to save a byte by omitting the `o` in `o.png`.

    I changed it to `show` instead of saving but your idea won't work because a valid filename is required for saving and `.png` isn't one.

    Can't you do `from PIL import*` and then use `Image` instead of `I` and `ImageDraw` instead of `D`?

    Already tried that but it seems that PIL doesn't include submodules in the `__all__` variable. This means no starred import :(

    If you do `from PIL.ImageDraw import*`, `I` becomes `Image` and `D.Draw` becomes `Draw`, saving 11 bytes.

    Thank you, it worked! But I counted 12 bytes instead of 11.

    Replace `'#fff'` with `~0` to save 4 more bytes ;) (*Note, I removed the apostrophes as well, just `~0` not `'~0'`)

    Thanks! It also works with `-1` which equals to your solution.

  • x86 real-mode machine code for DOS COM, 69 65 63 62 bytes



    Iceland flag produced



    The code is meant to be executed as a DOS COM executable.



    Special thanks




    • meden, saved four bytes.

    • meden, saved two bytes and removed the flickering.



    Machine code (in hex bytes)



    68 00 A0 07 B8 13 00 CD      10 BE 23 01 AD 91 AD 91 
    AC E3 FE 60 30 ED F3 AA 61 81 C7 40 01 FE CD 75
    F2 EB E9 FA B4 00 00 09 28 B4 46 00 0F FA 28 80
    57 0F 14 B4 0C 50 00 FA 14 0C 00 64 00 00


    Assembly source



    Source is for NASM.



    ORG 100h

    push 0a000h
    pop es

    mov ax, 13h
    int 10h

    mov si, data


    _draw:
    lodsw
    xchg ax, cx

    lodsw
    xchg ax, di

    lodsb

    _cycle:
    jcxz _cycle

    ;al = color
    ;cl = col
    ;ch = row

    rect:
    pusha
    xor ch, ch
    rep stosb
    popa
    add di, 320
    dec ch
    jnz SHORT rect

    jmp SHORT _draw


    data:

    db 250d
    db 180d
    dw 0000h
    db 09h


    db 40d
    db 180d
    dw 0070d
    db 0fh


    db 250d
    db 40d
    dw 22400d
    db 0fh

    db 20d
    db 180d
    dw 80d
    db 0ch


    db 250
    db 20
    dw 25600d
    db 0ch


    dw 0000h

    This is a really cool first answer! Welcome!

    You can save 2 bytes by replacing 'mov' with 'xchg' at 10h & 13h and another 2 bytes by replacing 'test cx,cx/jz' with 'jcxz' at 16h

    Some more thoughts. Since the program runs in the infinite loop, you can avoid flickering just by making the loop shorter: `_loop: jcxz _loop`. You can also cut 2 bytes from the end of the data chunk if you change the loading order of `cx` and `di`

    Thanks again @meden. The flickering was completely unnecessary in effect :) I also removed the `mov bx, 320` and moved the *320* into `add di, 320` (previously `add di, bx`).

    Great. Now you've got a firm edge over all machine code answers in this challenge. Just for the sake of correctness: it'd better to move `jcxz _cycle` right after `xchg ax,cx` so it wouldn't load bytes past the end of the data. And there's some misleading comments in the source: `;dx = row`. `dx` is not used anywhere in code.

    @meden I actually prefer the `jcxz` where it is, It makes the code a little bit more "uniform" (de gustibus). Reading past the end of the defined data is not a matter in RM, even at the end of the segment. I updated the comment though. Thanks again.

  • C, 194 191 183 Bytes



    #define C "\x1b["
    #define A "@@@@@@"
    y;f(){for(;y++<14;)printf(y>5&&y<10?y>6&&y<9?C"31m"A A A A"@\n":C"0m"A"@@"C"[email protected]@"C"0m"A A"@@@\n":C"34m"A"@"C"[email protected]"C"[email protected]@"C"[email protected]"C"34m"A A"@@\n");}


    -3 adding one @ on the #define A

    -8 adding [ on #define C



    Usage



    main(){f();}


    Output



    image



    valid basing on this comment from the OP



    Double Size Output, 204 Bytes



    #define C "\x1b["
    #define B "████"
    #define A B B B
    y;f(){for(;y++<28;)printf(y>10&&y<19?y>12&&y<17?C"31m"A A A A"██\n":C"0m"A B C"31m"B C"0m"A A B"██\n":C"34m"A"██"C"0m██"C"31m"B C"0m██"C"34m"A A B"\n");}


    image2


    the 5th upvote triggered a +810 rep network wide... Thanks! (Yes it's the first site where i reach the 200 rep :D)

    Doesn't the result have to be "at least 100 x 72 units, where a unit is a pixel or a character"? This doesn't meet this requirement, but I suspect the OP made a mistake when formulating that definition.

    @Kritzefitz Well, a character takes up many pixels, so it can be a pixel instead of a character. Found a hole.

    @GiacomoGarabello Whats the first site in the at pic where you got +150? I don't recognise the icon.

    @LegoStormtroopr It's PPCG!! Take a look at this GitHub Project!

  • Excel VBA, 254 228 153 bytes



    Couldn't really find a way to set column/row size to pixels(thereby making them square) because of the way Excel handles it so make them nice and square first.



    Edit 1: Replaced RGB with returned values for colors, -26 bytes



    Edit 2: Tried to add as many suggestions as I could, -75 bytes. I was not able to use &48e0 as a color and I am not sure why. Thanks everyone



    Sub e()
    c "A1:CV72", rgbBlue
    c "AC1:AR72", -1
    c "A29:CV44", -1
    c "AG1:AN72", 255
    c "A33:CV40", 255
    End Sub

    Sub c(d, f)
    Range(d).Interior.Color = f
    End Sub


    Picture:
    Iceland Flag


    How did you make the cells square? Did you do it manually, or with some other script not included? I'd like to see it, even if it's not part of your scored program.

    I did it manually, the code to change the cell width is easy enough where I could have added it but the sizes aren't consistent between Row/Column or monitor resolutions unless you set the size based on pixels which can't be done from what I could find. From what I read you have to find the resolution and do some math to convert the pixels to the size the function accepts.

    Also the code to convert it to pixels looks like it requires you hard code either some part of the resolution or PPI (I don't really understand the formula) so it seems it wouldn't work across all devices either.

    You can save *more* space with `r = &hd72828`, `w = -1` and using `&48e0` for blue. You can also use `sub x(r, c)`, `Range(r).Interior.Color = c`, `end sub` and replace those five lengthy lines with something like `x "a1:cv72", &48e0` and `x "a33:cv40", r`.

    I think you can also refer to multi-part ranges which should make it a little smaller, e.g. `x "ac1:ar72,a29:cv44", w` for both the horizontal *and* vertical white strips.

    And, just for completeness (to do with setting up square cells rather than the solution itself), if you switch to page layout view, you can set cell height and width to specific values like `0.2cm`. This will be maintained once you switch back, and no need to try and work out the bizarre Excel aspect ratios :-) By the way, if you want some more cool Excel tricks, look up Joel Spolsky's "You suck at Excel" video.

    I think extra whitespace can be removed, even though it is added automatically later.

    I was not able to get it to work that way paxdiablo, maybe I don't understand how it's suppose to work? Also, I was not able to get a multi part range to work. I actually tried that before I posted the answer but it just selects the entire rectangle instead of the two small areas.

    I Count 202. setting w and r is more bytes then its just to use the numbers twice. `Sub b()` `Range("A1:CV72").Interior.Color=rgbBlue` `Range("AC1:AR72").Interior.Color=-1:Range("A29:CV44").Interior.Color=-1` `Range("AG1:AN72").Interior.Color=255:Range("A33:CV40").Interior.Color=255` `End Sub`

    Nice to see someone using VBA; to make cells square within the code use `Columns.ColumnWidth = 2.14`. This matches the default height of the rows, and so makes all the cells square.

    You could probably make the range command set a separate sub and lose quite a few bytes.

    Drawing the flag into the top 18x25 cells gives a perfectly respectably sized flag, and loses some extra bytes. `Sub e():c "A1:Y18",rgbBlue:c "H1:K18",-1:c "A8:Y11",-1:c "I1:J18",255:c "A9:Y10",255:End Sub` and `Sub c(d,f):Range(d).Interior.Color=f:End Sub` comes in at 138 including 2 line feeds.

    I think cells would be considered pixels and fall into the 100 x 72 category.

    For future reference a `Cells.ColumnWidth=2` call can be used to make all of the cells square; also you can condense `c "AG1:AN72", 255 *\n* c "A33:CV40", 255` to `c "AG1:AN72,A33:CV40", 255` and like wise for the `c` call that proceeds it

    Also, you were not able to use `&48e0` because the hex value that you want it to represent corresponds to t `&HE04800` in VBA.

  • MATL, 57 56 52 49 48 bytes


    7:g2IvtPvt!9Mh2$X>2YG[0E28]8*255/7B[43DD]51/v2ZG

    This produces the following figure (tested with the compiler running on Matlab and on Octave).


    enter image description here


    EDIT: You can experimentally try at MATL Online! (you may need to reload the page if it doesn't work initially).


    How it works


    7:g         % Range from 1 to 7 converted to logical: push array [1 1 1 1 1 1 1]
    2 % Push 2
    I % Push 3
    v % Concatenate vertically into a 9×1 array
    tPv % Duplicate, flip vertically, concatenate. Gives a 18×1 array
    t! % Duplicate, transpose: 1×18 array
    9M % Push [1 1 1 1 1 1 1] again
    h % Concatenate horizontally: gives 1×25 array
    2$X> % Maximum of the two arrays, with broadcast. Gives a 18×25 array
    % with 1 for blue, 2 for white, 3 for red
    2YG % Show image with default colormap
    [0E28]8* % Push array [0 72 224] (blue)
    255/ % Divide each entry by 255. Colors are normalized between 0 and 1
    7B % 7 converted into binary: push array [1 1 1] (white, normalized)
    [43DD]51/ % Push array [215/255 40/255 40/255] (red, normalized)
    v % Concatenate vertically. Gives a 3×3 array
    2ZG % Use as colormap

  • Bash + Imagemagick 7, 94 90 86 85 bytes



    magick -size 84x56 xc:#0048e0 ${s=-splice 8x8}+28+28 -background \#d72828 $s+32+32 x:





    Saved 8 bytes, thanks to @manatwork, and 1 byte, thanks to @GlennRanders-Pehrson


    If you specify `x:` instead of output file name, `convert` will display the result in a window, which is also acceptable. And is enough to just escape the sharp, no need to quote: `\#d72828`.

    Usually we label such answers as *Bash + Imagemagick*. On `bash` side you can save another 4 characters: `convert -size 84x56 xc:#0048e0 ${s=-splice 8x8}+28+28 -background \#d72828 $s+32+32 x:`.

    Just a stupid question: Can you do `${s=-splice 8x8}+56`?

    @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ `+56` is treated as `+56+0`, not `+28+28`.

    You can save another byte by using a recent version of ImageMagick; then the command can be "magick" instead of "convert".

    @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ, `-splice`'s argument is geometry, superset of X's geometry.

  • CSS, 285 284 264 bytes



    *,:before,:after{background:#fff;width:100;height:72}body{background:#0048e0;margin:0}:before,:after{content:"";position:fixed}:after{background:#d72828}html:before{top:28;height:16}body:before{left:28;width:16}html:after{top:32;height:8}body:after{left:32;width:8


    Saved 1 byte thanks to @insertusernamehere.



    Saved 20 bytes thanks to @user2428118, by removing all the pxs. Note that this requires the page to be rendered in quirks mode, so it doesn't work in Stack Snippets.



    I could copy the Python approach of wrapping an image around at an offset, but it wouldn't be interesting to.



    Ungolfed:





    *, *::before, *::after {
    background: #fff;
    width: 100px;
    height: 72px;
    }

    body {
    background: #0048e0;
    margin: 0;
    }

    *::before, *::after {
    content: "";
    position: fixed;
    }

    *::after { background: #d72828 }

    html::before { top: 28px; height: 16px }
    body::before { left: 28px; width: 16px }
    html::after { top: 32px; height: 8px }
    body::after { left: 32px; width: 8px }





    This uses the pseudo-elements (elements that aren't written in HTML) ::before and ::after to create the lines on the flag. The reason it works with no HTML is that in HTML5 the <html> and <body> elements are optional, so browsers automatically create them if they're not present.



    More fun:





    *, *::before, *::after {
    background: white;
    width: 100px;
    height: 72px;
    }

    body {
    background: #0048e0;
    margin: 0;
    }

    *::before, *::after {
    content: "";
    position: fixed;
    }

    *::after { background: #d72828 }

    html::before { top: 28px; height: 16px }
    body::before { left: 28px; width: 16px }
    html::after { top: 32px; height: 8px }
    body::after { left: 32px; width: 8px }

    @keyframes change-color {
    from { filter: none }
    50% { filter: hue-rotate(360deg) }
    to { filter: none }
    }

    @keyframes transformations {
    from { transform: translate(150%, 100%) rotateZ(0deg) scale(0.7) }
    15% { transform: translate(150%, 100%) rotateZ(54deg) scale(1.8) }
    to { transform: translate(150%, 100%) rotateZ(360deg) scale(0.7) }
    }

    html {
    animation:
    0.7s linear infinite change-color,
    1s linear infinite transformations;
    }




    You can still save *1 byte* by replacing `white` with `#fff`.

    @insertusernamehere Yep, thanks.

    If you apply the CSS in quirks mode (page without doctype) you can bring it down to 264 bytes by omitting `px` everywhere.

    @user2428118 Even more useful considering that there's no HTML, therefore no ``!

    @user2428118 For some reason it doesn't work for me in mobile Safari. I'll have a look when I'm next at a computer.

    @gcampbell Stack snippets automatically insert a doctype.

    You can replace "::" with just ":" to save 9 bytes

    @SolomonUcko I've only used `::` in the ungolfed version.

  • ZX Spectrum BASIC, 210 141 92 bytes



    1 LET n=-VAL "8.5": FOR y=n TO -n: FOR x=n TO VAL "16": LET p=VAL "271"(PI-(ABS x<SQR PI OR ABS y>SQR PI)-NOT INT ABS x*INT ABS y): PRINT PAPER p; BRIGHT p>PI;" ";: NEXT x: PRINT : NEXT y


    enter image description here



    Size determined as the size of the BASIC program on tape via SAVE. A lot of the golfing credit to some members of the ZX Spectrum group on Facebook, in particular @impomatic and Johan Koelman.


    Seeing those `PAPER` and `BRIGHT` brings so many good memories :-)

    Is there any info on how much memory a ZX Spectrum BASIC program takes? I thought it was a "tokenized" language, i.e. I expected `FOR`, `NOT` etc to take up only 1 or maybe 2 bytes each

    @LuisMendo Yes, it is tokenized - `FOR` is precisely one byte. However, numbers are "anti-tokenized" in that they are stored as both their text and *binary* forms and take up 5 more bytes than you'd expect, hence `NOT PI` instead of zero and the like.

    132 bytes by removing the AT and adjusting the boundary test https://twitter.com/john_metcalf/status/752760203007791105

    Sorry for the _basic_ question :-P How do I save and load this program into the Fuse emulator?

    I love this answer :-)

  • ZX Spectrum Z80 Assembly, 65 bytes



        ld hl,22528
    ld b,7
    ld de,120*256+8 ; white, blue
    ld a,16 ; red

    ; create the first row

    blueleft:
    ld (hl),e
    inc hl
    djnz blueleft

    ld (hl),d
    inc hl
    ld (hl),a
    inc hl
    ld (hl),a
    inc hl
    ld (hl),d
    inc hl

    ld b,14
    blueright:
    ld (hl),e
    inc hl
    djnz blueright

    ; copy the first row to the next 17 rows

    ld l,b
    ld de,22528+32
    ld bc,17*32
    ldir

    ; add the horizontal stripe

    ld hl,22528+7*32
    dec d
    ld e,b
    ld c,2
    midrep:
    ld b,25
    midstripe:
    cp (hl)
    jr z,red
    ld (hl),120
    red:
    ld (de),a
    inc hl
    inc de
    djnz midstripe

    ld hl,22528+10*32
    ld e,9*32
    dec c
    jr nz,midrep
    ret


    Icelandic Flag


  • Minecraft 1.10.2, 734 characters


    It might be 734 characters, but it's the only submission so far made of actual wool!


    summon FallingSand ~ ~1 ~ {Block:log,Time:1,Passengers:[{id:FallingSand,Block:redstone_block,Time:1,Passengers:[{id:FallingSand,Block:activator_rail,Time:1,Passengers:[{id:MinecartCommandBlock,Command:"fill 0 ~ 0 100 ~ 72 wool 11"},{id:MinecartCommandBlock,Command:"fill 28 ~ 0 44 ~ 72 wool"},{id:MinecartCommandBlock,Command:"fill 0 ~ 28 100 ~ 44 wool"},{id:MinecartCommandBlock,Command:"fill 32 ~ 0 40 ~ 72 wool 14"},{id:MinecartCommandBlock,Command:"fill 0 ~ 32 100 ~ 40 wool 14"},{id:MinecartCommandBlock,Command:setblock ~ ~ ~1 command_block 0 replace {Command:fill ~ ~-3 ~-1 ~ ~ ~ air}},{id:MinecartCommandBlock,Command:setblock ~ ~-1 ~1 redstone_block},{id:MinecartCommandBlock,Command:kill @e[type=MinecartCommandBlock]}]}]}]}

    Go to about -5x -5z, paste into an Impulse command block, set it to "Always Active" and press Done.


    Flag spans from 0, 0 to 100, 72; and is 3 blocks above the command block as placed. It casts a fairly large shadow, and monsters spawn under it. Whether this is accurate to the country of Iceland, however, is anyone's guess.


    Fair warning - will /kill all MinecartCommandBlocks in the world in the interest of saving four characters. Don't run this in a world you're overly attached to.


    Flag


    Used MrGarretto's command combiner and tweaked the output a little bit (808 -> 734)


    "Whether this is accurate to the country of Iceland..."

    Can't you just use kill @e without the target selector argument? It'll kill the player but hey the flag will still be there

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM