New answers tagged

1

C (gcc) (MinGW), 277 276 bytes -1 byte thanks to @ceilingcat Added -lm compiler flags to TiO for illustrative purposes, but MinGW does not need it. Outputs a 3-shade PGM file to STDOUT. q,i,c;main(s,v)char**v;{float u=atoi(v[1])/12.,d,r;q=u*15;for(*v=memset(calloc(q,q+1),2,i=q*q);i--;i[*v]-=d<6&d>5|r>6&r<7|r>8&r<9&&r&...


4

Python 3.8 (pre-release), 1533 bytes def w(n,ll,ans): global p,q from math import sin,cos,pi,atan2 def y(s,e,f,a,b): x,y=f(s),f(e) g=lambda a,b,x:0<=(x-a)%2<=b-a while e-s>1e-15: m=(s+e)/2 z=f(m) if x*z<=0: e,y=m,z else: s,x=m,z &#...


4

Google Sheets, 277 bytes =ARRAYFORMULA((POW(COLUMN(A1:CV99)-5*A1,2)+POW(ROW(A1:CV99)-5*A1,2)<A1*A1)+(POW(COLUMN(A1:CV99)-5*A1,2)+POW(ROW(A1:CV99)-5*A1,2)>9/4*A1*A1)*(POW(COLUMN(A1:CV99)-5*A1,2)+POW(ROW(A1:CV99)-5*A1,2)<25*A1*A1)*IFERROR((MOD(3*ATAN2(COLUMN(A1:CV99)-5*A1,ROW(A1:CV99)-5*A1)/PI(),2)<1),0 Creates a grid of 1s and 0s which can be ...


2

Mathematica (Wolfram Language) 76 71 Bytes This solution draws the radiation symbol using only the Disk[] primitive, which allows for arcs. By default a Graphics object in Mathematica has a White background and objects are Black unless otherwise specified. So we first draw three black disk sectors, then a small white disk and finally a smaller inner black ...


1

Runic Enchantments, 216 bytes D::i</~1-:0)?;{:}ak$2?X2 8?1]$#'~~\1?7 c?1$ '~~\?3 L R:0)?/1-:̹{2,::}}-S{-2pS2p+'qA:{5,:}≮?/:}3,2*S:}S≯?/5,)?/]:̹{2,:}-S{-:̹'-A}'-A0)3*?P2?Z0]{{S:0)a*?:0(4*?~~10,'|A'aA{0)?S-:0≮4*?P2*+3*2P*%P)4*?'#2?' $] Try it online! Dear god. Why. So much went wrong. It makes me cry. Several major impediments that ended ...


3

Mathematica, 93 88 85 76 74 70 bytes RegionPlot[1.5<#<5&&Sin[3#2]>0||#<1&@@AbsArg[x+I y],{x,-5,5},{y,-5,5}] -4 bytes thanks to Roman. It is not clear from the description whether it is required to get rid of the outline and make it black on white, but I think the submission looks best and is shortest like this.


2

PostScript, 183 175 bytes Code (compressed version): 20 20 scale 9 6 translate<</f{closepath fill}/c{0 360 arc f}/l{10 0 lineto -60 rotate}>>begin 0 0 5 c 1 setgray 3{0 0 moveto l l f} repeat 0 0 1.5 c 0 setgray 0 0 1 c showpage Code (uncompressed version): 20 20 scale % over-all scale 9 6 translate % over-all shift % ...


4

Desmos/Cartesian Plane, 103 97 86 84 bytes (23 arithmetic and comparison operators) (abs(mod(arctan(x,-y)/\pi*6,4)-2)-1)*max(0,182-abs(x^2+y^2-218))+max(0,16-x^2-y^2)>0 https://www.desmos.com/calculator/hadw7gayfn


1

OpenSCAD, 153 bytes module a(){polygon([[0,0],[5,0],[5,10]]);}module b(){a();rotate(120)a();rotate(240)a();}circle();intersection(){difference(){circle(5);circle(1.5);}b();} Uncompressed: module triangle() { polygon(points=[[0,0],[5,0],[5,10]]); } module triangles() { triangle(); rotate(120) triangle(); rotate(240) triangle(); } module ...


2

Python 3.8, 129 124 122 120 119 def f(N):[print((abs(a:=(i%N+i//N*1j)*2/N-1-1j)<.2)+((a**3).imag<0<.3<abs(a)<1),end=(-i%N==1)*"\n")for i in range(N*N)] Output (N=20): 00000000000000000000 00000000000000000000 00000100000000010000 00011100000000011100 00011110000000111100 00111111000001111110 01111111000001111111 01111111100011111111 ...


2

Ruby, 91 100 bytes ->s{(w=-(s/=2)..s).map{|x|w.map{|r|a=x*x+r*=r;' O'[a<(b=s*s)/25||a>b/11&&a<b&&x*(r*4-a)<0?1:0]}*''}} Try it online! Accepting 1 parameter (size of the image). Example output for s=40: O O OO OO OOOOO OOOOO ...


14

SVG(HTML5), 128 126 124 120 bytes (Thanks Wheat Wizard for saving 2 bytes by using .2 rather than 0.2) (Drawing triangles from right to left saves 2 bytes) (Thanks Grimmy for saving 2 bytes by using a modified path) (And reduced another 2 bytes by using a different starting point on the path) <svg viewbox=-2,-2,4,4> <circle r=1 /> <...


4

Logo, 96 bytes circle 16 rt 90 repeat 3[arc 80 60 arc 24 60 pu repeat 2[fw 24 pd fw 56 pu backward 80 rt 60]pd] Try it online! Draws just the border.


11

JavaScript (ES7),  118 113 98  93 bytes Saved 15 bytes thanks to @tsh! Takes a parameter \$w\$ as input and draws an ASCII art of width \$2w-1\$ and height \$2w\$, using 0 and 1 for the 'pixels'. f=(x,w=y=x)=>y+w?(--x+w?(r=x*x+y*y,4*x*x>r^y<0?1019:3)>>r**.5/w*10&1:(x=w,y--,` `))+f(x,w):'' Try it online! How? We compute the ...


1

GLSL / Shadertoy, 181 bytes void mainImage(out vec4 o,vec2 c) { vec2 p=(c-iResolution.xy/2.)/iResolution.y; float k=length(p),h=acos(-1.)/3.; o=step(0.,min(k-.1,max(k-.5,.15-k)*step(mod(atan(p.y,p.x),h+h),h)))-o; } Copy and paste this code into the editor then press the play button to run the shader. The shader uses the signed distance of the ...


6

Haskell (code.world dialect), 108 86 bytes drawingOf(c(2)&colored(c(3),white)&0%1&2%3&4%5) c=solidCircle a%b=sector(a*60,b*60,10) Run on code.world!


33

BBC BASIC, 200 bytes f=500 g=1/SQR(3) CIRCLE FILLf,f,f GCOL15 MOVE-100,f MOVEf,f PLOT85,f*(1-g),0 MOVE1100,f MOVEf,f PLOT85,f*(1+g),0 MOVEf*(1-g),2*f MOVEf,f PLOT85,f*(1+g),2*f CIRCLE FILLf,f,150 GCOL0 CIRCLE FILLf,f,100 Somehow outgolfing Python, this works by drawing a large black circle, filling in the white triangular sections, drawing a central white ...


7

C (gcc) (MinGW), 245 244 242 236 223 221 bytes -6 bytes thanks to ceilingcat. Added -lm on TiO so that it works there. MinGW does not require it. Outputs a 3-shade PGM file to STDOUT. Takes width (height is the same) of image as a command line argument. main(q,v,r,c,m)char**v;{*v=calloc(q+1,q=atoi(v[1]));float R=q/10.1,d;for(r=m=q/2;r--+m;)for(c=m;c--+m;...


14

Jelly, 42 bytes ÷ÆṬ÷ØPḂ×3ḞḂ æịA©>5,1.5aç^/o®Ị¤ ×5ŒR÷µçþAZY Try it online! A full program that takes an integer n that determines the radius of the central circle and implicitly outputs to STDOUT a \$10n+1\$ square with the desired image encoded as 1 for black and 0 for white. Per @flawr, this is a permitted output format. Note also that this is ...


4

TikZ, 170 bytes \documentclass[tikz]{standalone}\begin{document}\tikz{\fill circle(10);\foreach\a in{0,120,240}{\fill[white]circle(3)--(\a-60:13)--(\a:13);}\fill circle(2)}\end{document}


4

Red, 237 218 bytes Red[needs: 'View] g: func[n][a: compose[arc(s: n / 2.0 * 50x50)(s)60 60 closed rotate 120(s)]view compose/deep[base(s * 2)draw[(f: 'fill-pen)black(a)(a)(a) pen gray line-width(0.1 * s/1)(f)black circle(s)(s/1 / 4.0)]]] Takes a parameter n - the width/height in multiples of 50.


3

python 3.8, 220 from PIL import Image as I from math import* d=300 h=d//2 r0=d/10 g=range(-h,h) i=I.frombytes('L',(d,d),bytes([255,0][1.5<(r:=(x*x+y*y)**.5)/r0<5 and(atan2(x,y)/pi+7/6)*1.5%1.>.5 or r<r0]for y in g for x in g)) i.show() The idea behind is very simple: we count (x,y) from the center of image and r=(x*x+y*y)**.5 is the distance ...


17

MATL, 46 44 41 bytes :t_0vSt!Yy1MZ;3*YP/koyG.3*>*yG<*wG5/<=3YG Given an input n, the image has width 2*n+1 in pixels. Try it at MATL Online! Explanation : % Implicit input n. Range [1 ... n] t_ % Duplicate, negate. Gives [-1 ... -n] 0 % Push 0 v % Concatenate stack as a column vector: [1; ...; n; -1; ...; -n; 0] S % ...


14

SVG(HTML5), 175 bytes <svg viewBox=-24,-24,48,48><circle r=4 /><path id=b d=M3,-5.2A6,6,0,0,1,6,0H20A20,20,0,0,0,10,-17.32z /><use href=#b transform=rotate(120) /><use href=#b transform=rotate(240) Originally based on @Arnauld's answer, but removes unnecessary characters, scales the numbers by 80% to make them golfier, ...


7

HTML / SVG,  201  189 bytes A revamped version of this file from Wikimedia Commons. <svg viewBox=-30,-30,60,60><circle r=5 /><path id=b d=M7.5,0A7.5,7.5,0,0,0,3.7,-6.5L12.5,-21.6A25,25,0,0,1,25,0z /><use href=#b transform=rotate(120) /><use href=#b transform=rotate(240) />


0

Jelly, 23 bytes ×ḤÆS÷ÆS²¥_ÆTİ×ɗS ØP÷ç÷4 Try it online! A full program that takes the number of sides as its first argument and the list of folds as its right. Returns/prints the area of the folded polygon. Loosely based on the formula in @Arnauld’s answer.


Top 50 recent answers are included