| Bytes | Lang | Time | Link |
|---|---|---|---|
| 126 | TIBASIC TI83 Plus | 250527T194911Z | madeforl |
| 165 | SVG | 250525T055950Z | Miro |
| 113 | R | 250202T164221Z | Glory2Uk |
| 190 | Python 3 + pycairo | 241022T102559Z | david |
| 180 | Python 3.10 + Turtle | 241025T131249Z | SevC_10 |
| 111 | PICO8 | 250126T203538Z | Josiah W |
| 463 | MS SQL Server Management Studio | 241030T184825Z | jdt |
| 100 | C GCC | 241130T181946Z | matteo_c |
| 221 | AWK | 241030T175823Z | xrs |
| 210 | C64 BASIC | 241103T182019Z | jdt |
| 127 | Python 3 | 241101T123602Z | GuitarPi |
| 228 | Chipmunk Basic | 241031T020016Z | roblogic |
| 099 | Shadertoy GLSL | 241026T022041Z | Vicente |
| 043 | GFABasic 3.51 Atari ST | 241021T215301Z | Arnauld |
| 125 | SVG | 241022T073743Z | Hand-E-F |
| 039 | TinyAPL | 241022T172229Z | noodle p |
| 058 | SVG | 241020T210107Z | Level Ri |
| 023 | Wolfram Language Mathematica | 241022T164503Z | ZaMoC |
| 112 | PNG | 241022T153958Z | Jordan |
| 021 | Uiua | 241021T221055Z | noodle p |
| 012 | Desmos | 241020T210050Z | emanresu |
| 030 | Uiua | 241021T075350Z | mousetai |
| 140 | ZX Spectrum Basic | 241021T084905Z | Neil |
| 043 | TinyAPL | 241020T203219Z | RubenVer |
TI-BASIC (TI-83 Plus), 126 bytes
I don't think this counts as a passing answer but I just had to try
0→Xmin
18→Xmax
0→Ymin
12→Ymax
ΔX→U
Circle(7,6,4
For(A,0,3,U
Line(A,0,A,6
End
For(A,11,18,U
Line(A,0,A,6
End
Horizontal U
For(A,16,56
60→B
Repeat pxl-Test(B,A
Pxl-On(B,A
B-1→B
End
Line(AU,6,AU,BΔY
End
Don't have your grid on.
It looks exactly like the Greenland flag, except the red is black.
I have no way of currently showing the output, so you just gotta take my word for it. :(
SVG, 165 bytes
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 9 6"><path fill="#fff" d="M0 0h9v6H0"/><path fill="red" d="M0 3h9v3H0m1.5-3a2 2 0 0 0 4 0 2 2 0 0 0-4 0"/></svg>
HTML, 130 bytes
<svg viewBox="0 0 9 6"><path fill="#fff" d="M0 0h9v6H0"/><path fill="red" d="M0 3h9v3H0m1.5-3a2 2 0 0 0 4 0 2 2 0 0 0-4 0"/></svg>
(without xmlns)
R, 113 bytes
barplot(rbind(1,1),co=a<-c(2,0),bo=0);par(new=T,fig=c(0,.88,.12,.88),mar=c(1,0,0,0)+1.8);pie(c(1,1),NA,co=a,bo=0)
In order to get the png-file with the correct dimensions (as below):
png(filename="greenland.png", width=567, height=429)
barplot(rbind(1,1),co=a<-c(2,0),bo=0);par(new=T,fig=c(0,.88,.12,.88),mar=c(1,0,0,0)+1.8);pie(c(1,1),NA,co=a,bo=0)
dev.off()
Explanation:
The first barplot() plots two horizontal bars, a white and a pinkish one. par() with new=TRUE redirects the graphic output to the same graph window, in order to overlay the graphs. The arguments fig and mar were optimized by trial and error in order to fulfill the flag pattern ratios. Finally, pie() plots a pie chart with 2 sections, without labels (NA), the same colors as in the barplot and without border.
Python 3 + pycairo, 199190 bytes
Golfed 9 bytes thanks to @musava-ribica and different import
from cairo import*
x=Context(SVGSurface("g",18,12))
s=x.set_source_rgb
f=x.fill
r=7,6,4,0,3.14
s(1,1,1)
x.paint()
s(1,0,0)
x.rectangle(0,6,18,6)
x.arc_negative(*r)
f()
s(1,1,1)
x.arc(*r)
f()
Python 3.10 + Turtle, 184 180 bytes
The script draws the flag with minimum dimensions 18x12.
Edit:
-4 bytes thanks to @WeirdGlyphs
from turtle import*
x=setx
b=begin_fill
def c():circle(4,180);end_fill()
setup(18,12)
ht()
color(1,0,0)
b()
x(-6)
x(-9)
sety(-6)
x(9)
sety(0)
x(2)
seth(90)
c()
color(1,1,1)
b()
c()
Result:
PICO-8, 111 bytes
cls()rectfill(0,0,89,59,1)circfill(35,30,20,2)poke(24414,68)rectfill(0,30,89,59,4)pal({7,8,0,0,8,7},1)while(1)?
The bottom half of the flag has its color changed using a rectangle drawn on bitplane 2.
MS SQL Server - Management Studio, 483 463 bytes
CREATE TABLE F(P GEOMETRY)
DECLARE @c geometry=geometry::Point(0,0,0).STBuffer(4)
DECLARE @t geometry='POLYGON((-7 6,11 6,11 0,-7 0,-7 6))'
DECLARE @b geometry='POLYGON((-7 -6,11 -6,11 0,-7 0,-7 -6))'
DECLARE @i INT=1
WHILE @i<802 BEGIN INSERT INTO F(P)VALUES('POLYGON((0 0,1e-9 1e-9,0 1e-9,0 0))');SET @i=@i+1;END
INSERT INTO F(P)VALUES(@t.STDifference(@c).STUnion(@b.STIntersection(@c))),(@t.STIntersection(@c).STUnion(@b.STDifference(@c)))
SELECT*FROM F
More of a hot pink than red:
640 bytes to get a nicer red by overlapping the geometries:
CREATE TABLE #R(P GEOMETRY)
DECLARE @c geometry=geometry::Point(0,0,0).STBuffer(4)
DECLARE @t geometry='POLYGON((-7 6,11 6,11 0,-7 0,-7 6))'
DECLARE @b geometry='POLYGON((-7 -6,11 -6,11 0,-7 0,-7 -6))'
DECLARE @e geometry='POLYGON((0 0,1e-9 1e-9,0 1e-9,0 0))'
DECLARE @i INT=1
WHILE @i<802 BEGIN INSERT INTO #R(P)VALUES(@e);SET @i=@i+1;END
INSERT INTO #R(P)VALUES(@t.STDifference(@c).STUnion(@b.STIntersection(@c))),(@t.STIntersection(@c).STUnion(@b.STDifference(@c)))
SET @i=0
WHILE @i<5 BEGIN INSERT INTO #R(P)VALUES(@e);SET @i=@i+1;END
INSERT INTO #R(P)VALUES(@t.STIntersection(@c).STUnion(@b.STDifference(@c)))
SELECT*FROM #R
C (GCC), 101 100 bytes
- -1 byte thanks to @ceilingcat
i;main(k){for(puts("P6 18 12 1");i<648;putchar(i<324^i/54*(i/54-11)+k*(k-13)<-57|i++%3<1))k=i%54/3;}
Outputs a PPM image.
AWK, 221 bytes
func p(a,b){for(;a--;)printf(b?"\033[97m":"\033[31m")"█"}{n=$1;r=n/2;for(y=-r+2;y++<r-2;){g=n*y<r;p(int(2*r/3),g)
for(x=-r;x++<r;)x*x+y*y*4<r*r?p(1,!g):p(1,g);p(n,g);print"";if(!y){p(int(2*r/3))p(n-1,1)p(n+1);print""}}}
Fixed so it should now scale without getting into an infinite loop:
awk 'func p(a,b){for(;a--;)printf(b?"\033[97m":"\033[31m")"█"}{n=$1;r=n/2;for(y=-r+2;y++<r-2;){g=n*y<r;p(int(2*r/3),g)
for(x=-r;x++<r;)x*x+y*y*4<r*r?p(1,!g):p(1,g);p(n,g);print"";if(!y){p(int(2*r/3))p(n-1,1)p(n+1);print""}}}' <<< 30
C64 BASIC, 210 bytes
1pO53265,187:pO53272,24
2fOy=0to199:fOx=0to319:pO1024+x*y/62,18
3a=8192+int(y/8)*320+int(x/8)*8+(yaN7)
4c=abs(((116-x)^2+(100-y)^2>4356)=(y>100)):b=7-(xaN7):q=pE(a)
5pOa,(qor2^b)*(1-c)+(qaN(nO2^b))*c:nE:nE
6gO6
Draws the flag in high-res graphics mode in about 4 hours.
Python 3, 127 bytes
This uses XOR for the alternating colors, and a distance formula for the circle, and some ANSI codes for the color changes. Changing to black after every character instead of when done with a line saved 2 bytes. I could probably cheat a couple more bytes by finding resolutions that would let me omit decimals, maybe saving another 4 bytes but there would probably be some rounding errors. The solution as it stands can be adjusted for other resolutions.
for y in range(12):
for x in range(18):print("\033[4"+("7"if(y<6)^((x-6.5)**2+(y-5.5)**2<16)else"1"),end="m \033[0m")
print()
Chipmunk Basic, 252 225 228 bytes
graphics 0:k(0):graphics fillrect 0,60,180,120:t=pi/2
for i=t to t*3 step.002:k(0):p(i):k(99):p(i+pi):next
sub p(a):x=70+sin(a)*40:graphics moveto x,60:graphics lineto x,60+cos(a)*40:return
sub k(c):graphics color 99,c,c:return
Install v368b202 (MacOS) to test - the online compiler doesn't do graphics. Corrected artefacts by filling the semi-circles with vertical lines instead of radiating from the centre. Circle is now centred at (70,60) - was incorrectly placed at (90,60) before.
Description
1: k(0) :set colour to red, draw the lower rectangle, let t = π/2
2: loop from right of circle (angle t) to left (t*3)
k(0):p(i) :red line at angle i
k(99):p(i+pi) :white line at angle i+π
3: sub p(a) :draw a line segment from (90,60) (x,60) to (x,y) given by sin() and cos()
4: sub k(c) :change pen colour using chipmunk basic's RGB range of (0-100)
Shadertoy (GLSL), 99 bytes
void mainImage(out vec4 a,vec2 b){a=vec4(1,vec3(b.y<225.^^distance(vec2(262.5,225.),b)<150.?0:1));}
Arguably cheating since the shader has to be run at just the right resolution (450x675) for the image to be correct, which Shadertoy doesn't even support, but I was too excited about the XOR trick to not share :)
GFA-Basic 3.51 (Atari ST), 43 bytes
A manually edited listing in .LST format. All lines end with CR, including the last one.
SET 15,1792
PC 35,30,20
GR 3
PB 0,30,90,60
Expanded and commented
SETCOLOR 15,1792 ! set color #15 to 0x700 = red
PCIRCLE 35,30,20 ! draw a filled circle of radius 20 at (35,30)
GRAPHMODE 3 ! set the drawing mode to XOR
PBOX 0,30,90,60 ! draw a filled rectangle from (0,30) to (90,60)
Output
SVG, 127 125 bytes
<svg viewBox=".5,0,9,6"><path fill="red" d="M10,0V6H0V0"/><path fill="#FFF" d="M0,0V3H2A2,2,0,116,3A2,2,0,112,3h9V0"/></svg>
Expanded:
<svg viewBox=".5,0,9,6">
<path fill="red" d="
M 10,0
V 6
H 0
V 0
"/>
<path fill="#FFF" d="
M 0,0
V 3
H 2
A 2,2 0 1 1 6,3
A 2,2 0 1 1 2,3
h 9
V 0
"/>
</svg>
TinyAPL, 43 39 bytes*
⎕DisplayImage 1∘⍪⍤⍪⍨◠⊖⍤~⊸⍪4≥⍉|7-18⊕⊞⍥⍳6
Try it: TinyAPL REPL
-4 thanks to RubenVerg for telling me that some parentheses were unnecessary and suggesting a clever way to get around parentheses in (⍳6).
This is based on my Uiua solution.
Explanation:
18⊕⊞⍥⍳6 - the 18x6 table of complex numbers (0..17)+(0..5)i.
⍉|7- - subtract the real parts from 7, get the magnitude (\$ \sqrt{a^2+b^2} \$) of each, and transpose. This gives a 6x18 grid where each cell contains its distance to (0, 7).
4≥ - Is each distance greater than or equal to 4? This gives a zero for pixels in the circle and a one for pixels outside.
⊖⍤~⊸⍪ - Prepend a reversed, inverted copy of the array. This adds on the top half of the flag, yielding a 12x18 boolean array. The booleans still have to be mapped to colors.
1∘⍪⍤⍪⍨◠ - To each value, prepend a one and itself, giving a length-3 array. This maps zeroes to 1,0,0 and ones to 1,1,1, which correspond to red and white respectively in RGB colors. The result is a 12x18x3 array representing the image.
⎕DisplayImage - Self-explanatory.
*Encoded with 1 byte per character using (⎕Import"std:sbcs")→Encode.
SVG, 60 58bytes
Tested in Chrome and Edge. 1 byte saved thanks to Neil and 1 byte of whitespace deleted.
<svg><path d="M0 30h55a20 20 0 1 0 0 1h35v29H0"fill="red">
Drawn at 5 times the scale in the question (maybe I can go lower for less bytes.) The trick here is that the circle is not quite complete. There is a tiny gap in the white section on the right hand side. We start at centre left, move to the right of the circle, complete an arc with nominal 0 degree (or with large arc flag set, 360 degree) rotation (with a tiny vertical offset to let SVG know the correct circle orientation), move to the centre right of the flag, the bottom rightand finally to the bottom left. The path is not explicitly closed but this works in most browsers.
SVG, 56 54 48 bytes
Drawn at the scale in the question, which apparently is the min allowable. This version incorporates all golfs from emanresu, shaggy and ccprog and still works in Chrome and Edge despite the nonstandard syntax.
<svg><path d=M0,6h11a4,4,0,100,.1h7v6H0 fill=red
PNG, 112 bytes
Hand-drawn pixel art compressed by ImageOptim.
00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 .PNG........IHDR
00000010: 0000 0012 0000 000c 0802 0000 00e0 707a ..............pz
00000020: eb00 0000 3749 4441 5478 0163 f84f 16a0 ....7IDATx.c.O..
00000030: 92b6 0b3c c670 845f 1ba6 1ec2 3a19 d0f4 ...<.p._....:...
00000040: 6022 aa6a c325 8ddf 380a b4c1 117e 3d98 `".j.%..8....~=.
00000050: da10 88a0 1e84 365c 88fa da00 d530 b520 ......6\.....0.
00000060: 0d47 c1d5 0000 0000 4945 4e44 ae42 6082 .G......IEND.B`.
Uiua, 29 24 21 bytes
∵[1.]⊂¬⇌.≤4⌵⊞ℂ⇡6-7⇡18
Try it: Uiua pad
Golfed 24 -> 21 bytes thanks to Mousetail.
Output, upscaled:
I used the circle equation \$ \sqrt{(x-h)^2+(y-k)^2} \le r \$, with 6 and 7 substituted for \$ h \$ and \$ k \$, and \$ r^2 \$ being inlined as 16. Rather than squaring and square rooting, Mousetail suggested using the magnitude of the complex number x+yi, saving 3 bytes. Instead of drawing the whole circle and inverting half of it, I drew half of the circle and joined on top a reversed and inverted copy.
Multiplying each number except for the leading one by some fixed factor will give the flag at a higher resolution. Here's the output of multiplying each by ten: Uiua pad
Desmos, 12 bytes
(r-4)sinθ<0
As is somewhat standard with Desmos graphical-output, this uses the graph settings to frame/colour the image appropriately and remove background settings, which isn't included in the byte count. r-4 is negative within the circle of radius 4 around the origin, and sinθ is negative below the x-axis, so the image is red where exactly one of these is negative.
An alternate that only draws the part of the image in frame, for 33 bytes (leading newline is necessary to paste properly):
(xx+yy-16)y<0\{-7<x<11\}\{y>-6\}
Uiua, 39 30 chars
-:1⋯×6=⊞⊃(>4⌵ℂ-5.5|>5)⇡12-7⇡18
Uiua, 29 chars - More faded red
-⋯×6=⊞⊃(>4⌵ℂ-5.5|>5)⇡12-7⇡18η
Red is faded since it is the color [1, pi/4-1, pi/4-1] = [1, 0.214, 0.214] which is probably red enough.
ZX Spectrum Basic, 140 bytes
10 DIM a$(PI*PI): FOR i=SGN PI
TO PI: PRINT BRIGHT SGN PI; INK
VAL "2";a$: NEXT i: FOR i=SGN P
I TO PI: PRINT BRIGHT SGN PI; IN
K VAL "7"; PAPER VAL "2";a$: NEX
T I: LET a=VAL "15": FOR i=-a TO
a: FOR j=-a TO a: PLOT INK VAL
"8"; INVERSE i*i+j*j>VAL "255";i
+VAL "28",j+VAL "152": NEXT j: N
EXT i
The above shows how the program lists in 48K mode or with the LIST command. Explanation: 24 rows and 72 columns of pixels are drawn in bright white with a red foreground, then another 24 rows are drawn in red with a bright white foreground. A solid circle is then drawn at the appropriate position; INK 8 avoids changing the foreground colour, so the circle takes on the colour of the two rectangles. VAL and PI are used to avoid integer constants which would otherwise cost six extra bytes each.
TinyAPL, 43 bytes
⎕DisplayImage{1⍪2⌿0>⍵×8-|⍵⊕15}◠13-⊕⍆¨⍳24‿36
Many thanks to @emanresu A for -25 with a change in approach.
Result:
Explanation:
⎕DisplayImage{1⍪2⌿0>⍵×8-|⍵⊕15}◠13-⊕⍆¨⍳24‿36
⊕⍆¨⍳24‿36 ⍝ complex number matrix from 1+i to 24+36i
13- ⍝ 13 minus that, i.e. matrix from 12-i to -11-36i
{ }◠ ⍝ for each element of the matrix
⍵⊕15 ⍝ add 15i, i.e. matrix from 12+14i to -11-21i
| ⍝ magnitude
8- ⍝ 8 minus that
⍵× ⍝ multiplied by the original element
0> ⍝ is negative?
1⍪2⌿ ⍝ [1, x, x] -> [1, 0, 0] (red) or [1, 1, 1] (white)
⎕DisplayImage ⍝ show image in editor
💎
Created with the help of Luminespire.



















