Draw the Biohazard symbol in an arbitrary colour on a distinctly coloured background. The specific proportions were published in the June 27th 1974 issue of the Federal Register of the US Government.


  • As output, writing to a file (raster and vector formats are permitted) or displaying on the screen are both allowed.

  • You can draw just the border or the filled shape.

  • If you use raster images, you should take a parameter (or two) as input that lets you adjust the resolution of the output (e.g. width/height).

  • The background must at least have the size of the bounding box of the symbol but may be larger.

  • Outputting the unicode symbol ☣ is not sufficient.

  • The exact ratios of the used distances are given in following diagram (which was originally from here):

I also tried to make an additional diagram with the same measurements that is hopefully a little bit easier to read:

(Inspired by a post on 99%invisible)

  • 2
    \$\begingroup\$ Loophole: can we just put a 1x1 pixel image inside a variable sized background? \$\endgroup\$ – John Dvorak Sep 4 '19 at 13:49
  • \$\begingroup\$ I don't think it is, if you set the resolution large enough the symbol should still appear. And in any case I hope people here have enough common sense to understand what we mean:) \$\endgroup\$ – flawr Sep 4 '19 at 14:11
  • 1
    \$\begingroup\$ If I had time to spare I would give it a try with PostScript or turtle graphics. \$\endgroup\$ – Guy Coder Sep 4 '19 at 14:46
  • 1
    \$\begingroup\$ @SriotchilismO'Zaic The length is determined by the two circles: They each have a given center and radius, so the length is determined by the size of the gap. \$\endgroup\$ – flawr Sep 5 '19 at 13:09
  • 1
    \$\begingroup\$ That is "E" in the original diagram (the crosses represent the circle centers), and \$11\$ in the one I added below (where the radius meets the axis of symmetry). \$\endgroup\$ – flawr Sep 5 '19 at 13:13

18 Answers 18


T-SQL, 442 441 426 355 349 344 bytes

DECLARE @ VARCHAR(MAX)=REPLACE(REPLACE(REPLACE('DECLARE @a5MULTIPOINT((0 31),(19 -2),(-19 -2))'',@b5MULTIPOINT((0 39),(26 -6),(-26 -6))'',@5POINT(0 9)'',@d5LINESTRING(0 9,0 99,90 -43,0 9,-90 -43)''SELECT @a830%b821)%86)%d81)%d84%819))).STUnion(@827%820)).STIntersection(@b819)))'
,8,'.STBuffer('),5,' GEOMETRY='''),'%',').STDifference(@')EXEC(@)

Saved 70+ bytes by using REPLACE() for long keywords and executing as dynamic SQL. See the post-replacement code in the screenshot below.

I doubled the coordinate values from the sample illustration and moved up 9 units, to reduce the number of decimals displayed.

This was done in SQL 2017, using geo-spatial features introduced in SQL 2008. Lots of useful built-in geometry functions, including STBuffer, which gives me a simple way to define circles of different sizes around a point.

Visual of output, with annotated code:

Biohazard symbol in T-SQL using geo-spatial functions

For more T-SQL drawing, see my Easter Bunny.

For more practical applications of this tech in SQL, read this article or watch this video. SE even has a related site, gis.stackexchange.com.


  1. Saved 1 byte by changing a coordinate from 104 to 99.
  2. Saved 15 bytes by taking the STDifference of a STUnion of objects, instead of each individually.
  3. Saved 71 bytes by using REPLACE() on repeated keywords, then executing as dynamic SQL. Reverted Edit 2, to leave more replacements of STDifference.
  4. Saved 4 bytes by moving the center up 9 units, which changed a few coordinates to single (negative) digits. This also freed up the numeral 5 to use as a replacement character instead of '#', saving 2 more bytes on the quotes.
  5. Saved 5 bytes by moving ) into the STDifference replacement string; thanks, @Nicholas!
  • 62
    \$\begingroup\$ Why... does this exist? \$\endgroup\$ – Alexander Sep 5 '19 at 1:55
  • 28
    \$\begingroup\$ @Alexander For databases that contain or use geographic data, like population census, or scientific studies, or even just customer sales by geographic region. Or just for drawing bunnies and biohazard symbols. \$\endgroup\$ – BradC Sep 5 '19 at 2:54
  • 26
    \$\begingroup\$ SQL is bad enough for the one thing it's meant for, who in their right mind would want to go beyond that. Imagine GUIs written in SQL. I need annotations, aspects, and a unit testing framework. We need to go deeeeeper. \$\endgroup\$ – Alexander Sep 5 '19 at 3:26
  • 24
    \$\begingroup\$ @Alexander As you wish: TSQLT \$\endgroup\$ – FreeMan Sep 5 '19 at 14:35
  • 18
    \$\begingroup\$ @FreeMan Oh for f...'s sake. \$\endgroup\$ – Alexander Sep 5 '19 at 14:49

Tex + Tikz, 232 bytes

43 bytes saved by switching to tex. Thanks to Phelype Oleinik

Some bytes saved thanks to Skillmon

\input tikz \tikz[x=1,y=1,white]{\def\f{\foreach\1in{90:,210:,330:}}\def\u{\draw[line width=}\def~{circle(}\f\fill[red](\122)~30);\f{\u2](0,)--(\111);\u8](\130)--(\160);\fill(\130)~21);}\fill~6);\u7,red]~23.5);\f\u2](\130)~20);}\bye

With line breaks and without \def:

\input tikz
\draw[line width=2](0,0)--(\1:11);
\draw[line width=8](\1:30)--(\1:60);
\draw[line width=7,red](0,0)circle(23.5);
\foreach\1in{90,210,330}\draw[line width=2](\1:30)circle(20);


This is a little outdated I will fix it when I can figure out how to make the images not enourmous

Here I am going to explain how the uncompressed answer solves the problem. I may at some point explain how the compression works. First we draw the big black circles:

\foreach\x in{90,210,330}\fill(\x:21)circle(30);

enter image description here

Then we draw some white lines:

\foreach\x in{90,210,330}\draw[white,line width=2cm](0,0)--(\x:11);

enter image description here

Then we draw white circles:

\foreach\x in{90,210,330}\fill[white](\x:30)circle(21);

enter image description here

Then we add a central white circle:


enter image description here

Then we add a black annulus:

\draw[line width=7cm](0,0)circle(25.5);

enter image description here

Then we remove parts of the black annulus

\foreach\x in{90,210,330}\draw[white,line width=2cm](\x:30)circle(20);

enter image description here

  • 9
    \$\begingroup\$ You haven't blunted the six outer points. There should be 4 units of white space between each pair. \$\endgroup\$ – Level River St Sep 4 '19 at 23:20
  • 1
    \$\begingroup\$ @LevelRiverSt The six outer points are now 4 units away from their partner. \$\endgroup\$ – Wheat Wizard Sep 5 '19 at 4:35
  • 2
    \$\begingroup\$ Those "claw tips" are too pointy, they should consist of straight line segments parallel to the segments coming from the center circle. Also the 20.88 looks quite suspicious. \$\endgroup\$ – flawr Sep 5 '19 at 6:42
  • \$\begingroup\$ You can save another byte by using \1 instead of \x, as you can then use \def\f{\foreach\1in{90,210,330}}. \$\endgroup\$ – Skillmon Sep 5 '19 at 9:26
  • 1
    \$\begingroup\$ @flawr well... they're now literally quite a bit smaller than 5000x5000... only 90x90 now... barely can make out the details :D \$\endgroup\$ – Nelson Sep 7 '19 at 17:03

C, 8010 bytes

Way back, before SVG or EMF, you had to deal with raster, and if you wanted something to load right away, say before the O/S was ready, like a Windows startup screen, you had to use RLE, or run-length-encoding. This monster outputs a PBM file using RLE as the data. Build like usual and run like this ./biohazard > biohazard.pbm.

If you were to include all the frameworks required to generate, e.g. the SVG engine in HTML, the Java libraries, etc. this would likely be the smallest self-contained solution, because puts is the only external function, and it's typically one of the smallest stdio.h functions.

Regarding this detail:

If you use raster images, you should take a parameter (or two) as input that lets you adjust the resolution of the output (e.g. width/height).

I interpreted "should" as different from "must", e.g. as in RFC 2119, so I didn't include scaling, because for this code it would only be feasible to do multiples of the original, e.g. ./biohazard 2 and that would introduce atoi, printf and other complications which would detract from the main focus of the submission.

int o,i,x[]=
main(){for(puts("P1\n432 408");x[i];++i,o=!o)while(x[i]--)puts(o?"0":"1");}
  • 1
    \$\begingroup\$ Would be nice to explain how you generated the code. \$\endgroup\$ – Cœur Sep 6 '19 at 16:06
  • \$\begingroup\$ The code outputs a newline after every character; I think you need putchar() or similar. \$\endgroup\$ – marcelm Sep 6 '19 at 20:36
  • \$\begingroup\$ @marcelm - PBM P1 format is okay with that! \$\endgroup\$ – user15259 Sep 6 '19 at 20:46
  • 2
    \$\begingroup\$ I'm pretty sure that should does mean must for this question, but that would probably be worth taking up with the OP. \$\endgroup\$ – Wheat Wizard Sep 6 '19 at 22:53
  • 2
    \$\begingroup\$ I don't think that using must necessarily means that there is a distinction. This is really a question you should (or perhaps must) ask the OP. \$\endgroup\$ – Wheat Wizard Sep 7 '19 at 23:44

TeX + TikZ, 234 230 226 224 bytes

Originally 5 bytes longer than Sriotchilism O'Zaic's answer, but this one should be correct. It is similar to his answer but saves a few bytes more here and there, it needs one \draw[line width=8] more (in the code below this is done by \28](~30)to(~55);, that's 17 bytes added only for this) to get the tips of the symbol right, hence the 5 bytes more overall code length.

  • thanks to Sriotchilism O'Zaic I reread some specifications of the question and realized I can change the colour to red, so that saves a few bytes again.

  • another two bytes were stripped thanks to Joe85AC's comment

\input tikz\let~\def~\1{circle(}~\2{~\draw[line width=}~~{\foreach~in{90:,210:,330:}}\tikz[x=1,y=1,white]{~\fill[red](~22)\130);~\fill(~30)\121);\28](~30)to(~55);\22](~0)to(~10);\fill\16);\27,red]\123.5);\22](~30)\120);}\bye

TeX-g + TikZ, 195 Bytes

Just if someone cares, the following uses a TeX-based code golf dialect that I'm working on (don't consider the code stable). The byte count includes EOL characters and the EOF character, as those are semantically used (EOL delimits arguments of loops). The dialect is pretty small up until now and only features shorthands for definitions and a for-loop syntax, however it is not specifically written for this answer, so it shouldn't break the rules of code golfing. Repository for the -g.tex-package/file: https://github.com/Skillmon/TeX-g

\input-g <tikz>~"{\:~{90:,210:,330:}}~'{circle(}~_{\draw[line width=}!f\fill\tikz[x=1,y=1,white]{"f[red](~22)'30);

Output of both code snippets looks identical:

enter image description here

(too lazy to update the image, just imagine it being red)

  • \$\begingroup\$ My answer is now correct and 2 bytes shorter than yours. I'm sure someone could probably combine some of my answer with some of yours to make a shorter one, but I don't quite understand your answer. \$\endgroup\$ – Wheat Wizard Sep 5 '19 at 13:48
  • \$\begingroup\$ @SriotchilismO'Zaic if I change the colour to red (overread the rule that the colour can be arbitrary), I get it to 230 bytes. \$\endgroup\$ – Skillmon Sep 5 '19 at 14:03
  • \$\begingroup\$ @SriotchilismO'Zaic and obviously you saved more than just one byte by in your answer by looking at mine (just saying). \$\endgroup\$ – Skillmon Sep 5 '19 at 14:06
  • 2
    \$\begingroup\$ @SriotchilismO'Zaic it's ok. My code is influenced by yours after all, I currently try to write a code golfing package to turn TeX into a code golfing language of some sort. When I finally published it my answer will be shorter :) (This is no language specifically crafted for this question, so it doesn't break the rules) \$\endgroup\$ – Skillmon Sep 5 '19 at 14:19
  • 1
    \$\begingroup\$ Took me quite a while but I managed to improve your result by another two bytes: \input tikz\def\c{circle(}\def\d{~\draw[line width=}\def~{\foreach~in{90:,210:,330:}}\tikz[x=1,y=1,white]{~\fill[red](~22)\c30);~\fill(~30)\c21);\d8](~30)to(~55);\d2](~0)to(~10);\fill\c6);\d7,red]\c23.5);\d2](~30)\c20);}\bye This was a very hard challenge for myself as you've done a near perfect job, IMHO. \$\endgroup\$ – Joe85AC Jun 2 '20 at 12:01

SVG(HTML5), 434 410 321 306 bytes

<svg viewbox=-60,-60,120,120><circle r=23.5 stroke-width=7 fill=#fff stroke=#000 /><use href=#g transform=scale(-1,1) /><g id=g><use href=#p transform=rotate(120) /><use href=#p transform=rotate(240) /><path id=p stroke=#fff stroke-width=2 d=M5,0A5,5,0,0,0,0,-5V-10A20,20,0,0,0,2,-50V-53A31,31,0,0,1,31,-17

Now based on @LevelRiverSt's SVG. Edit: Saved 12 bytes thanks to @G0BLiN.

  • 1
    \$\begingroup\$ I believe that omitting <defs> is safe. This works for me on Firefox, Chrome and Edge. \$\endgroup\$ – Arnauld Sep 4 '19 at 14:23
  • \$\begingroup\$ @Arnauld Thanks, that means I can get rid of the first <use> as well! \$\endgroup\$ – Neil Sep 4 '19 at 20:33
  • \$\begingroup\$ You can shorten this by drawing the symbol centered on x=0,y=0. Try this <svg viewbox=-60,-60,120,120><circle r=23.5 stroke-width=7 fill=#fff stroke=#000 /><use href=#g transform=scale(-1,1) /><g id=g><use href=#p transform=rotate(120) /><use href=#p transform=rotate(240) /><path id=p stroke=#fff stroke-width=2 d=M-5,0A5,5,0,0,1,0,-5V-10A20,20,0,0,1,-2,-50V-53A31,31,0,0,0,-31,-17 - should shorten this to 309 bytes. :) \$\endgroup\$ – G0BLiN Nov 27 '19 at 17:41
  • 1
    \$\begingroup\$ @G0BLiN Thanks, and I was able to save a further 3 bytes by drawing the mirrored version of the path (since it's reflected anyway). \$\endgroup\$ – Neil Nov 27 '19 at 19:56

Processing, 371 368 bytes

translate(width/2,width/2);scale(width/99);int i=0,b=204;float t=TAU/3;noStroke();for(;i<3;i++){fill(0);ellipse(0,-22,60,60);rotate(t);}for(;i<6;i++){fill(b);rect(-4,-60,8,16);ellipse(0,-30,42,42);rotate(t);}ellipse(0,0,12,12);stroke(0);strokeWeight(7);noFill();ellipse(0,0,47,47);for(;i<9;i++){strokeWeight(2);stroke(b);ellipse(0,-30,40,40);line(0,0,0,-9);rotate(t);}

I wasn't sure if Processing should count as rasterized or not for the purpose of this challenge. If it counts as rasterized, the translate and scale is necessary to make the symbol legible and on-screen for a given window size. But, because all of the drawing commands are vectorized, it works at any given scale; so if we assume drawing at the relative origin to be about 200 units wide is fine, the first 43 bytes can be dropped.

This assumes the background color is 204, 204, 204, which is the default background color in processing. It also assumes a rectMode of CORNER and an ellipseMode of CENTER (the defaults)

With an initial size(640, 640), the resulting sketch looks like this:

enter image description here

By doubling the scale, I saved 3 bytes, because .5s are eliminated (though several numbers do flow from 1 digit to 2 digit).

The construction is similar to the TeX solution, drawing black and then gray on top to "erase" the gaps between the shape.


translate(width/2,width/2); // Move to the middle of the canvas
scale(width/99);            // Scale up to fill the canvas

int i=0,b=204;              // Initialize i, and `b` to the background color
float t=TAU/3;              // Save a rotation of one third, in radians

for(;i<3;i++){ // Draw the three big black circles
  rect(-4,-60,8,16);     // "Blunt" the corners on the sharp outer rings
  ellipse(0,-30,42,42); // Cut out the middle of the big circles
ellipse(0,0,12,12); // Cut out the small circle in the middle
ellipse(0,0,47,47); // Draw the thick band that goes through all three big circles
  ellipse(0,-30,40,40); // Cut the "gap" between the three big rings
                        //and the band passing through them
  line(0,0,0,-16);      // Cut the lines coming out of the small middle circle
  • \$\begingroup\$ Looks nice:) I think if you double all the measurements you can avoid the .5! \$\endgroup\$ – flawr Sep 5 '19 at 6:54
  • \$\begingroup\$ Yes, but that'd also change some of the single digit number to double digit, so I'm not sure how it balances out. If I counted right, it looks like that would save 2 bytes. I was also thinking about using a scale to change it for only part of the code, but wasn't sure where to best put it \$\endgroup\$ – Curtis Fenner Sep 5 '19 at 7:17
  • \$\begingroup\$ oh you're right, I did not consider that. \$\endgroup\$ – flawr Sep 5 '19 at 7:19
  • \$\begingroup\$ Doubling the measurements to remove decimals saved almost 10 bytes in my answer, even though a few coords went from single to double digits. Worth a try, anyway. \$\endgroup\$ – BradC Sep 5 '19 at 16:53
  • 1
    \$\begingroup\$ I saved 3 bytes by doubling the scale it's drawn at. @IsmaelMiguel \$\endgroup\$ – Curtis Fenner Sep 12 '19 at 1:11

GLSL, 700 629 564 545 499 bytes

#define v vec2
#define j(x,r)length(x-g)<r
#define k(x,r,q)j(x,q)!=j(x,r)
#define l(b)length(g-b)<1.&&length(g-dot(g,b)*b)<(length(g)<S?A*S:A/S)
float C=.86,S=.5,F=.3,E=.22,A=.02,G=.21;void mainImage(out vec4 o,in v p){v r=iResolution.xy;v g=(p/S-r)/r.y;o.g=(k(v(0,F),G,G-A)||k(v(F*C,-F*S),G,G-A)||k(v(-F*C,-F*S),G,G-A))?o.g=0.:k(v(0),F,G)?C:l(v(0,1))||l(v(C,-S))||l(v(-C,-S))||j(v(0),.06)||j(v(0,F),G)||j(v(F*C,-F*S),G)||j(v(-F*C,-F*S),G)?0.:j(v(0,E),F)||j(v(E*C,-E*S),F)||j(v(-E*C,-E*S),F)?C:0.;}

I was playing around with Shadertoy, so I tried the GLSL shading language. The code just rasterizes circles and lines by testing each fragment, and assigns them a value of one or zero. The size was cut down from >1000 bytes by heavy use of macros.

Shadertoy program

enter image description here

  • 1
    \$\begingroup\$ Welcome to the site! Neat first answer! \$\endgroup\$ – Wheat Wizard Sep 6 '19 at 0:05
  • \$\begingroup\$ I don't know the language, but can the && and || be golfed to & and | at some or all parts? \$\endgroup\$ – Kevin Cruijssen Sep 6 '19 at 7:33
  • \$\begingroup\$ @KevinCruijssen It's a subset of C, so those would be bitwise operations. For me the compiler complains about type though \$\endgroup\$ – Roninkoi Sep 6 '19 at 8:01
  • 1
    \$\begingroup\$ @Roninkoi I indeed saw that it was based on C. In C it is possible to use |/& instead of ||/&& for bools, isn't it? Haven't done anything in C in a long time, so not sure. I know it works in Java/C# .NET in most cases. But I only now notice the Shadertoy link you've added, and it doesn't seem to work there as you've already stated. Ah well. Nice first answer btw! Welcome to CGCC. \$\endgroup\$ – Kevin Cruijssen Sep 6 '19 at 8:54
  • \$\begingroup\$ I cut -30 bytes on posted code but Header sais 566 bytes, and posted code is 628? \$\endgroup\$ – PrincePolka Sep 6 '19 at 20:56

PostScript, 367 359 328 271 bytes

Code (compressed version):

5 5 scale 36 24 translate <</c{0 360 arc closepath}/r{120 rotate}/R{repeat}/L{setlinewidth}/g{setgray}/F{fill}>>begin 3{0 11 15 c F r}R 1 g 3{0 15 10.5 c F r}R 0 0 3 c F 3{[-.5 2 1 3 -2 25 4 3]rectfill r}R 0 g 4 L 0 0 11.5 c stroke 1 g 1 L 3{0 15 10 c stroke r}R showpage

Code (uncompressed version):

5 5 scale                  % over-all scale
36 24 translate            % over-all shift

% define some short-named procedures for later use
  /c { 0 360 arc closepath }  % append circle (x, y, radius are taken from stack)
  /r { 120 rotate }           % rotate by 120°
  /R { repeat }
  /L { setlinewidth }
  /g { setgray }
  /F { fill }
>> begin

3 {
    0 11 15 c F       % black circle
    r                 % rotate by 120°
} R
1 g                   % set white color
3 {
    0 15 10.5 c F     % white circle
    r                 % rotate by 120°
} R
0 0 3 c F             % small white circle
3 {
    [ -.5 2 1 3       % white gap near center
      -2 25 4 3       % white gap on edge
    ] rectfill
    r                 % rotate by 120°
} R
0 g                   % set black color
4 L                   % set linewidth 4
0 0 11.5 c stroke     % black ring
1 g                   % set white color
1 L                   % set linewidth 1
3 {
    0 15 10 c stroke  % white ring
    r                 % rotate by 120°
} R

Result (as animation to see how it is drawn):


  • \$\begingroup\$ Great animation. \$\endgroup\$ – dana Sep 7 '19 at 20:33

GLSL, 319 310 bytes

#define F float
#define H(y)sqrt(x*x+(y)*(y))
void mainImage(out vec4 D,in vec2 u){vec2 U=u*.003-.5;F x=abs(U.x),y=U.y;if(y<.577*x){F t=.5*x+.866*y;y=.866*x-.5*y;x=abs(t);}F c=F(H(y-.11)<.15);F R=H(y);F S=H(y-.15);if(S<.105)c=0.;if(R<.03)c=0.;if(x<(R<.1?.005:.02))c=0.;if(R>.10&&R<.135&&S<.095)c=1.;D=vec4(c);}

This can be rendered on Shadertoy.


You can use the symmetry in the image to draw it with a smaller amount of separate shapes.

Here is a somewhat inflated version:

#define F float
#define H(y) sqrt(x*x+(y)*(y))

void mainImage(out vec4 D,in vec2 u)
    // normalized UV
    vec2 U = u*.003 - .5;
    // fold the 6 identical sections to the same UV coordinates
    F x = abs(U.x), y = U.y;
    if (y < .577*x)
        F t = .5*x + .866*y;
        y = .866*x - .5*y;
        x = abs(t);
    // circles and lines
    F c = F(H(y-.11) < .15);
    F R = H(y);
    F S = H(y-.15);
    if (S < .105) c = 0.;
    if (R < .03) c = 0.;
    if (x < (R < .1 ? .005 : .02)) c = 0.;
    if (R > .10 && R < .135 && S < .095) c = 1.;
    // output
    D = vec4(c);

(thanks to @Kevin Cruijssen for removing some unnecessary whitespace)

  • 1
    \$\begingroup\$ You can remove some of the spaces. The one in your define: H(y) sqrtH(y)sqrt; all the spaces at your if-statements: if (if(; and those in your last if-statement surrounding the ANDs: if (R>.10 && R<.135 && S<.095)c=1.;if(R>.10&&R<.135&&S<.095)c=1.;. \$\endgroup\$ – Kevin Cruijssen Sep 6 '19 at 16:22

Haskell, 530 491 436 435 430 420 bytes

u a p=any($p)a
i a p=all($p)a
h?r=[c(h*cos a,h*sin a)r|a<-v]
(h%y)x|u[i[u$11?15,(not.)$u$o 3:map(0#1)v++map(9#4)v++15?10.5],i[o 13.5,not.(o 10),u$15?9.5]](60*f x/h-30,60*f y/h-30)="0 "|0<1="1 "
g h|s<-show h,n<-[0..h-1]=writeFile"a.pbm"$unlines$"P1":(s++' ':s):[n>>=(f h%)y|y<-n]

Outputs a PBM file.

This was a lot of fun!


(I had to convert this to PNG to upload to imgur)

Basically we create our own vector graphics functions which render onto an image pixel by pixel by detecting whether the pixel is part of the shape. The shape is constructed as a bunch of circles and lines (radiating from the origin) held together with basic set operations: union, intersection, and not. The circles are composed of their center and a radius, and the lines have a minimum radius, a width, and an angle in that order. Detecting membership in a circle is easy: I just subtract the center coords and compare the magnitude to the radius. The line is slightly more complicated: I rotate the point by the opposite of the angle to bring it (to nullify the rotation) then I just check whether the x and y coordinates fall within the expected range. The minimum radius is to ensure the larger gap at the far ends of the large circles does not overrule the small gaps near the center. After that it's a simple matter of boolean logic to do set math.

EDIT: Thanks a lot to @flawr for taking off 39 bytes!

EDIT2: Thanks a lot to @Christian Sievers for taking off 55 bytes! Good idea making them into functions

EDIT3: Thanks again to @Christian Sievers for shaving off another byte!

EDIT4: Took off 7 bytes thanks to @H.PWiz and @Angs!

EDIT5: Just noticed a bug! I was rendering the lines twice as thick as they were supposed to be! Cost me 2 bytes to fix it (had to divide width by 2; could've adjusted the constant values but changing 1 to 0.5 would also cost 2).

EDIT6: Thanks @Angs for taking off another 10 bytes!

  • \$\begingroup\$ Wow, this is so cool. It is rare to see someone defining their own types in code-golf here:) Two questions: Is it necessary to have negative angles [-90,-210,-330]? And would it be possible to change the <= to <? \$\endgroup\$ – flawr Sep 6 '19 at 20:48
  • 1
    \$\begingroup\$ So I tried it and managed to shave a few bytes off \$\endgroup\$ – flawr Sep 6 '19 at 21:38
  • 1
    \$\begingroup\$ Oh, in case you didn't know, we have a haskell chat as well as some tips for golfing in haskell. \$\endgroup\$ – flawr Sep 6 '19 at 21:40
  • 1
    \$\begingroup\$ Another small tweak \$\endgroup\$ – flawr Sep 6 '19 at 21:53
  • 1
    \$\begingroup\$ Nice! It's possible without data type \$\endgroup\$ – Christian Sievers Sep 7 '19 at 13:39

Java 10, 860 bytes

import java.awt.*;v->new Frame(){{add(new Panel(){Color C;public void paint(Graphics g){var G=(Graphics2D)g;int t=300;G.fillOval(150,40,t,t);G.fillOval(55,205,t,t);G.fillOval(245,205,t,t);G.setColor(C.WHITE);G.fillOval(195,45,t=210,t);G.fillOval(65,270,t,t);G.fillOval(325,270,t,t);G.fillOval(270,270,60,60);G.fillRect(295,240,10,60);G.fillPolygon(new int[]{246,251,303,298},new int[]{326,334,304,296},4);G.fillPolygon(new int[]{298,349,354,303},new int[]{304,334,326,296},4);G.fillRect(280,0,40,80);G.fillPolygon(new int[]{30,50,119,99},new int[]{433,467,427,393},4);G.fillPolygon(new int[]{550,570,501,481},new int[]{467,433,393,427},4);G.setColor(C.BLACK);G.setStroke(new BasicStroke(35));G.drawOval(183,183,235,235);G.setColor(C.WHITE);G.setStroke(new BasicStroke(10));G.drawOval(200,50,t=205,t);G.drawOval(70,275,t,t);G.drawOval(330,275,t,t);}});show();}}

The byte count is only 303 bytes longer than the previous longest answer (excluding the 2k bytes C answer), haha.. Java I guess ¯\_(ツ)_/¯


enter image description here

And here with each part colored differently to see what is actually being drawn:

enter image description here


Unlike all other answers, rotating and drawing would be even longer in Java, so instead I'm using default draw methods. This unfortunately came with one big disadvantage: I need to know the \$x,y\$-coordinate of the top-left corner of the square surrounding the circle, and its width/height. As well as some more \$x,y\$-coordinates for rotated rectangles. This took A LOT of calculations to finally finish with this code and output.

The sizes are based on a center point at coordinate \$[300,300]\$, with 10 times the units mentioned in the picture of the challenge description as sizes for all shapes. Why 10 times as large? All the Java AWT methods require integers as pixel-coordinates, so using the default small units would become way to inaccurate when rounding to integers. By using a 10 times as large value it's still easy to calculate with, and the rounding errors are minimal (although still slightly noticeable to the naked eye - note: all decimals are rounded 'half up').

Code explanation:

// Required import for Frame, Panel, Graphics, Graphics2D, Color, and BasicStroke:
import java.awt.*;
// Method with empty unused parameter and Frame return-type
  // Create a Frame (window for graphical output)
  new Frame(){
    // Start an initialized block for this Frame
      // Add a Panel (where we can draw on) to the Frame
      add(new Panel(){
        // Color null-object on class-level to use for static calls and save bytes
        Color C;
        // Override it's default paint method
        public void paint(Graphics g){
          // Cast the Graphics to a Graphics2D-object, for the setStroke() method
          var G=(Graphics2D)g;
          // Temp integer to save bytes
          int t=300;
          // Draw the three large black circles (default color is black)
          // Then change the color to white
          // Draw the two smaller inner circles
          // As well as the small circle at the center of the bio-hazard symbol
          // Draw the three openings next to the middle circle
          G.fillPolygon(new int[]{246,251,303,298},new int[]{326,334,304,296},4);
          G.fillPolygon(new int[]{298,349,354,303},new int[]{304,334,326,296},4);
          // Create the three openings for the outer circles
          G.fillPolygon(new int[]{30,50,119,99},new int[]{433,467,427,393},4);
          G.fillPolygon(new int[]{550,570,501,481},new int[]{467,433,393,427},4);
          // Change the color back to black
          // Set the line thickness to 35 pixels
          G.setStroke(new BasicStroke(35));
          // Draw the circle that would form the arcs in the bio-hazard symbol
          // Change the color to white again
          // Set the line thickness to 10 pixels
          G.setStroke(new BasicStroke(10));
          // And draw the three rings alongside the earlier inner circles we drew,
          // to create gaps in the ring to form the arcs
     // And finally show the Frame


And now comes the long part: how are all these magic numbers in the code calculated?

As I mentioned earlier, I've used 10 times the units of the picture in the challenge description, so those sizes are: \$A=10, B=35, C=40, D=60, E=110, F=150, G=210, H=300\$. I've also assumed the very center is at coordinate \$[300,300]\$. Using just this information, I had to calculate all the magic numbers you see in the code, which I will go over down below:

1a) Top black circle:

Width/height: this is mentioned in the diagram: \$H=300\$.
\$x,y\$-coordinate top-left square corner: line \$E\$ goes from the center of the bio-hazard symbol (\$[300,300]\$) to the center of the black circle. So the coordinate at the center of this circle is therefore \$[300, 300-E]\$. From there, we can subtract halve the width/height from both the \$x\$ and \$y\$ coordinate of this center to get the coordinate of the top-left corner of the square surrounding the circle: \$[300-\frac{H}{2}, 300-E-\frac{H}{2}] → [150, 40]\$.

1b) Bottom-left black circle:

Width/height: again \$H=300\$.
\$x,y\$-coordinate top-left square corner: we again know the length of line \$E\$. We also know that the angle is at 330°. If we draw a triangle with \$E\$ as long side, and with the three corners as angles \$90,60,30\$, we can calculate the other two sides:

enter image description here

Here \$a=\frac{E}{2}\$ and \$c=\frac{E}{2}\sqrt{3}\$. So the center coordinates of this black circle is therefore \$[300-\frac{E}{2}\sqrt{3}, 300+\frac{E}{2}]\$. From there, we can again subtract halve the width/height from both to get the coordinate of the top-left corner of the square surrounding the circle: \$[300-\frac{E}{2}\sqrt{3}-\frac{H}{2}, 300+\frac{E}{2}-\frac{H}{2}] → [54.737, 205]\$

1c) Bottom-right black circle:

Width/height: again \$H=300\$.
\$x,y\$-coordinate top-left square corner: we do something similar as above, but in the other direction: \$[300+\frac{E}{2}\sqrt{3}-\frac{H}{2}, 300+\frac{E}{2}-\frac{H}{2}] → [245.262, 205]\$

2a) Top inner white circle:

Width/height: this is mentioned in the diagram: \$G=210\$.
\$x,y\$-coordinate top-left square corner: line \$F\$ goes from the center of the bio-hazard symbol (\$[300,300]\$) to the center of the inner white circle. So the coordinate at the center of this circle is therefore \$[300, 300-F]\$. From there, we can subtract halve the width/height from both the \$x\$ and \$y\$ coordinate of this center to get the coordinate of the top-left corner of the square surrounding the circle: \$[300-\frac{G}{2}, 300-F-\frac{G}{2}] → [195, 45]\$.

2b) Bottom-left inner white circle:

Width/height: again \$G=210\$.
\$x,y\$-coordinate top-left square corner: similar as what we did in step 1b: \$[300-\frac{F}{2}\sqrt{3}-\frac{G}{2}, 300+\frac{F}{2}-\frac{G}{2}] → [65.096, 270]\$

2c) Bottom-right inner white circle:

Width/height: again \$G=210\$.
\$x,y\$-coordinate top-left square corner: similar as what we did in step 1c: \$[300+\frac{F}{2}\sqrt{3}-\frac{G}{2}, 300+\frac{F}{2}-\frac{G}{2}] → [324.903, 270]\$

3) Center white circle:

Width/height: this is mentioned in the diagram: \$D=60\$.
\$x,y\$-coordinate top-left square corner: subtracting halve this width/height from the center coordinate is enough: \$[300-\frac{D}{2}, 300-\frac{D}{2}] → [270, 270]\$

4a) Top white rectangle gap at the center of the bio-hazard symbol:

Width: this is mentioned in the diagram: \$A=10\$.
Height: Not too irrelevant, as long as it's large enough to create the gap, and not too large to go over other thing that should remain black. So I've just used \$D=60\$ here.
\$x,y\$-coordinate top-left corner: \$[300-\frac{A}{2}, 300-D] → [295, 240]\$

4b) Bottom-left rectangle gap at the center of the bio-hazard symbol:

Single the rectangle is angled, the Java method fillPolygon(int[] xPoints, int[] yPoint, int amountOfPoints) doesn't need the width/height, but instead needs the four individual coordinates of the corners of this rectangle. By again creating multiple triangles with corner-angles at 90, 60, and 30 degrees with the long side known, we can calculate the other sides. The calculations of the four points in the order I've used them in the Java method are:
\$[300-\frac{D}{2}\sqrt{3}-\frac{A}{4}, 300+\frac{D}{2}-\frac{A}{4}\sqrt(3)] → [245.528, 325.669]\$
\$[300-\frac{D}{2}\sqrt{3}+\frac{A}{4}, 300+\frac{D}{2}+\frac{A}{4}\sqrt(3)] → [250.538, 334.330]\$
\$[300+\frac{A}{4}, 300+\frac{A}{4}\sqrt{3}] → [302.5, 304.330]\$
\$[300-\frac{A}{4}, 300-\frac{A}{4}\sqrt{3}] → [297.5, 295.669]\$

4c) Bottom-right rectangle gap at the center of the bio-hazard symbol:

Likewise as step 4b:
\$[300-\frac{A}{4}, 300+\frac{A}{4}\sqrt{3}] → [297.5, 304.220]\$
\$[300+\frac{D}{2}\sqrt{3}-\frac{A}{4}, 300+\frac{D}{2}+\frac{A}{4}\sqrt{3}] → [349.461, 334.330]\$
\$[300+\frac{D}{2}\sqrt{3}+\frac{A}{4}, 300+\frac{D}{2}-\frac{A}{4}\sqrt{3}] → [354.461, 325.669]\$
\$[300+\frac{A}{4}, 300-\frac{A}{4}\sqrt{3}] → [302.5, 295.669]\$

5a) Top big white gap:

Width: this is mentioned in the diagram: \$C=40\$.
Height: Not too irrelevant, as long as it's large enough to create the gap, and not too large to go over other thing that should remain black. So I've just used \$2\times\text{1a.y}=80\$ here.
\$x,y\$-coordinate top-left corner: \$[300-\frac{C}{2}, 0] → [280, 0]\$ The \$0\$ isn't calculated, it was just easier to use (as mentioned earlier, the height is mostly irrelevant).

5b) Bottom-left big rectangle gap:

Similar as step 4b for the first two points:
\$[300-\frac{H}{2}\sqrt{3}-\frac{C}{4}, 300+\frac{H}{2}-\frac{C}{4}\sqrt{3}] → [30.192, 432.679]\$
\$[300-\frac{H}{2}\sqrt{3}+\frac{C}{4}, 300+\frac{H}{2}+\frac{C}{4}\sqrt{3}] → [50.192, 467.320]\$

For the other two we can't base it on the center of the screen like we did in step 4b, but instead we'll calculate it based on the two points we've just calculated:

\$[300-\frac{H}{2}\sqrt{3}+\frac{C}{4}+\frac{80}{2}\sqrt{3}, 300+\frac{H}{2}+\frac{C}{4}\sqrt{3}-\frac{80}{2}] → [119.474, 427.320]\$ \$[300-\frac{H}{2}\sqrt{3}-\frac{C}{4}+\frac{80}{2}\sqrt{3}, 300+\frac{H}{2}-\frac{C}{4}\sqrt{3}-\frac{80}{2}] → [99.474, 392.679]\$
(where the \$80\$ is the \$2\times\text{1a.y}\$ mentioned in step 5a)

5c) Bottom-right big rectangle gap:

Likewise as step 5b:
\$[300+\frac{H}{2}\sqrt{3}-\frac{C}{4}, 300+\frac{H}{2}+\frac{C}{4}\sqrt{3}] → [549.807, 467.320]\$
\$[300+\frac{H}{2}\sqrt{3}+\frac{C}{4}, 300+\frac{H}{2}-\frac{C}{4}\sqrt{3}] → [569.807, 432,679]\$
\$[300+\frac{H}{2}\sqrt{3}+\frac{C}{4}-\frac{80}{2}\sqrt{3}, 300+\frac{H}{2}-\frac{C}{4}\sqrt{3}-\frac{80}{2}] → [500.525, 392.679]\$
\$[300+\frac{H}{2}\sqrt{3}-\frac{C}{4}-\frac{80}{2}\sqrt{3}, 300+\frac{H}{2}+\frac{C}{4}\sqrt{3}-\frac{80}{2}] → [480.525, 427.320]\$

6) Black ring that will form the arcs:

Thickness: this is mentioned in the diagram: \$B=35\$.
Width/height: this can be calculated with the units in the diagram: \$2(E-A+B) → 270\$, after which we'll remove the thickness: \$2(E-A+B)-B → 235\$ (halve the thickness at both sides)
\$x,y\$-coordinate top-left corner: we simply subtract halve the width/height from the center coordinate: \$[300-\frac{2(E-A+B)-B}{2}, 300-\frac{2(E-A+B)-B}{2}] → [182.5, 182.5]\$

7) White ring inside the inner circles to form the arcs:

Thickness: this is mentioned in the diagram: \$A=10\$.
Width/height: this is the same as step 2a: \$G=210\$, but with this thickness removed: \$G-A → 200\$
\$x,y\$-coordinate top-left corner: these are the same calculations as in step 2a, but with the adjusted width/height \$G-A\$ instead of \$G\$:
\$[300-\frac{G-A}{2}, 300-F-\frac{G-A}{2}] → [200, 50]\$
\$[300-\frac{F}{2}\sqrt{3}-\frac{G-A}{2}, 300+\frac{F}{2}-\frac{G-A}{2}] → [65.096, 270] → [70.096, 275]\$
\$[300+\frac{F}{2}\sqrt{3}-\frac{G-A}{2}, 300+\frac{F}{2}-\frac{G-A}{2}] → [324.903, 270] → [329.903, 275]\$

And rounding all those values we've calculated to integers we get the code and output above.

  • 1
    \$\begingroup\$ Can g.fillOval be assigned to a variable in Java? I think it occurs enough times for that to save bytes. \$\endgroup\$ – the default. Sep 5 '19 at 14:19
  • \$\begingroup\$ @someone Ah yeah, I did that in the rabbit challenge earlier and planned on doing it here after I was done, but forgot.. Thanks, will fix it right away and see how much it saves. :) \$\endgroup\$ – Kevin Cruijssen Sep 5 '19 at 14:21
  • \$\begingroup\$ I have the impressions the proportions are somehow off. The bottom one of those three parts crossing the central "ring" looks a thinner than the other two. And I have the impression that those "claws" don't quite look right, unfortunately I cannot exactly say what seems off. \$\endgroup\$ – flawr Sep 5 '19 at 14:23
  • 1
    \$\begingroup\$ This answer is still wrong. The edges of the ring sections are supposed to be curved to match the circles they are within. Also, the gaps at the outside look too wide. I understand you're trying to be golfy, but compromises that change the output from what it's supposed to be aren't really allowed. \$\endgroup\$ – mbomb007 Sep 7 '19 at 17:09
  • 1
    \$\begingroup\$ @flawr It's been a while (a year and 3 days I now notice xD), but I've just fixed the code. It required A LOT of calculations, but I'm glad everything is correct now. \$\endgroup\$ – Kevin Cruijssen Sep 10 '20 at 15:58

HTML / JS,  448 435 433  387 bytes

Saved many bytes by using @Neil's pre-minimized version of the SVG
Saved 2 bytes thanks to @Shaggy

A compressed version of this SVG file from Wikimedia Commons.

<body onload="_=`<svg~12y~24y><path id=p d=m28.8117,27.046a3,3}0qb3117q4.004v-1w539|1wq20.7959v-w583a1jxb7975x7.3228xj,8.6032x9.7443l-.4835q.2792|-18.7598q9.0989zm3.4148q8.871a10x0}0q1b453,c9w,9w{-kx3wx3w}1x6.8042,0x0x0{k>~><use href=#p transform=rotate(},cc|a10wx0w}c{}1qb1756,yc26,26) /x,1w.5q,-kb7417j5x5}1c0,b2.`;for(i of`bcjkqwxy{|}~`)with(_.split(i))_=b.innerHTML=join(pop())"id=b>

Try it online! (just outputs the decompressed string)

Demo snippet

setTimeout(_ => document.getElementsByTagName('svg')[0].setAttribute("viewBox", "0 0 100 100"), 0)
<body onload="_=`<svg~12y~24y><path id=p d=m28.8117,27.046a3,3}0qb3117q4.004v-1w539|1wq20.7959v-w583a1jxb7975x7.3228xj,8.6032x9.7443l-.4835q.2792|-18.7598q9.0989zm3.4148q8.871a10x0}0q1b453,c9w,9w{-kx3wx3w}1x6.8042,0x0x0{k>~><use href=#p transform=rotate(},cc|a10wx0w}c{}1qb1756,yc26,26) /x,1w.5q,-kb7417j5x5}1c0,b2.`;for(i of`bcjkqwxy{|}~`)with(_.split(i))_=b.innerHTML=join(pop())"id=b>

  • \$\begingroup\$ This works, on CodePen in Chrome Android, for 392. \$\endgroup\$ – Shaggy Sep 4 '19 at 21:30
  • 1
    \$\begingroup\$ @Arnauld I have inverted my answer, although it cost 5 bytes (I found another unnecessary byte though so overall my score only went up by 4). \$\endgroup\$ – Neil Sep 5 '19 at 8:53
  • \$\begingroup\$ @Neil Updated accordingly. ;) \$\endgroup\$ – Arnauld Sep 5 '19 at 11:26
  • \$\begingroup\$ It turns out that @LevelRiverSt's SVG is much smaller! \$\endgroup\$ – Neil Sep 8 '19 at 11:47

Ruby, 278 bytes

puts"<svg viewBox='-60-60 120 120'><circle cx='0'cy='0'r='23.5'stroke-width='7'fill='white'stroke='red'/>",(-3..5).map{|i|"<path fill='red'stroke='white'stroke-width='2'd='M5 0A5 5 0 0 1 0 5v5A20 20 0 0 1 2 50v3A31 31 0 0 0 31 17'transform='scale(#{i/3},-1)rotate(#{i*120})'/>"}

Try it online!

Generates the SVG code below, with the symbol being at 200% of the scale in the OP.

It consists of a circle at the back, and the prongs in the foreground. The prong is scaled -1,0,1 in the X axis and rotated through multiples of 120 degrees. The cases where the X scaling is zero produce no output, while the -1 and +1. provide the two sides of each pair of prongs.

Use is made of a 2-unit wide white border around the prong to cut the back circle, using the stroke and stroke-width attributes. In order for the internal shape to be per the OP, the coordinates are moved by 1 unit (half the width of the border.) Note that the path is deliberately not closed, to suppress the drawing of the final line of the border. This ensures the two halves of each pair of prongs join together.

90 degrees of the inner circle are drawn rather than the expected 60, for golfing reasons. This means there is some overlap between the bases of each pair of prongs, but this does not affect the appearance of the output shape.

<svg viewBox='-60-60 120 120'><circle cx='0'cy='0'r='23.5'stroke-width='7'fill='white'stroke='red'/>
<path fill='red'stroke='white'stroke-width='2'd='M5 0A5 5 0 0 1 0 5v5A20 20 0 0 1 2 50v3A31 31 0 0 0 31 17'transform='scale(-1,-1)rotate(-360)'/>
<path fill='red'stroke='white'stroke-width='2'd='M5 0A5 5 0 0 1 0 5v5A20 20 0 0 1 2 50v3A31 31 0 0 0 31 17'transform='scale(-1,-1)rotate(-240)'/>
<path fill='red'stroke='white'stroke-width='2'd='M5 0A5 5 0 0 1 0 5v5A20 20 0 0 1 2 50v3A31 31 0 0 0 31 17'transform='scale(-1,-1)rotate(-120)'/>
<path fill='red'stroke='white'stroke-width='2'd='M5 0A5 5 0 0 1 0 5v5A20 20 0 0 1 2 50v3A31 31 0 0 0 31 17'transform='scale(0,-1)rotate(0)'/>
<path fill='red'stroke='white'stroke-width='2'd='M5 0A5 5 0 0 1 0 5v5A20 20 0 0 1 2 50v3A31 31 0 0 0 31 17'transform='scale(0,-1)rotate(120)'/>
<path fill='red'stroke='white'stroke-width='2'd='M5 0A5 5 0 0 1 0 5v5A20 20 0 0 1 2 50v3A31 31 0 0 0 31 17'transform='scale(0,-1)rotate(240)'/>
<path fill='red'stroke='white'stroke-width='2'd='M5 0A5 5 0 0 1 0 5v5A20 20 0 0 1 2 50v3A31 31 0 0 0 31 17'transform='scale(1,-1)rotate(360)'/>
<path fill='red'stroke='white'stroke-width='2'd='M5 0A5 5 0 0 1 0 5v5A20 20 0 0 1 2 50v3A31 31 0 0 0 31 17'transform='scale(1,-1)rotate(480)'/>
<path fill='red'stroke='white'stroke-width='2'd='M5 0A5 5 0 0 1 0 5v5A20 20 0 0 1 2 50v3A31 31 0 0 0 31 17'transform='scale(1,-1)rotate(600)'/>


Python 3 with pygame, 327 314 287 278 bytes

(Applied various nasty hacks to save 13 bytes; most notably no longer storing the color but calculating it on the fly with -(r>25))
(Refactored to function, losing sys; hacked out math in favour of coordinate constants; small tweaks; saved 27 bytes)
(Rewrote coordinate constants to complex math tricks to get (co)sine, saving 9 bytes)

Function that takes a single integer argument representing half the width/height of the resulting image. E.g. f(500) will create a 1000x1000 pixel window, and draw a biohazard symbol in there.

from pygame import*;D=display
def f(S):
 for p,r,w in(22,30,0),(30,20,0),(0,27,7),(30,21,2),(0,6,0),(51,4,0):
  for l in 0,4/3,8/3:Z=1j**l*p*b;q=S+int(Z.imag),S-int(Z.real);draw.circle(u,-(r>25),q,r*b,w*b);r-20or draw.line(u,0,(S,S),q,b*2);D.flip()

Unshortened version:

import pygame
import math
import sys

size = int(sys.argv[1])
basic = size // 55

screen = pygame.display.set_mode((size * 2, size * 2))

circles = [
    (22, 30, 0, -1),  # basic shape
    (30, 20, 0, 0),   # large cutouts
    (0, 27, 7, -1),   # "background circle"
    (30, 21, 2, 0),   # "background circle" clearance
    (0, 6, 0, 0),     # center disc
    (51, 4, 0, 0),    # blunt the points

for pos, radius, width, color in circles:
    for lobe in [0, math.pi * 2 / 3, math.pi * 4 / 3]:
        x = int(math.sin(lobe) * pos * basic) + size
        y = size - int(pos * basic * math.cos(lobe))
        pygame.draw.circle(screen, color, (x, y), radius * basic, width * basic)
        # Hack to draw the small slots in the center
        if radius == 20:
            pygame.draw.line(screen, 0, (size, size), (x, y), basic * 2)


The key to this program is mostly exploiting the 3-way point symmetry of the symbol, and expressing the drawing operations as sparsely as possible. The heart of it all is circles, which is a list of circle definitions, consisting just of:

  • position: how far outwards from the origin in half basic units
  • radius: the radius of the circle in half basic units
  • width: the border width of the circle (inwards from the outer circle, 0 = fill)
  • color: exploiting the fact that pygame interprets 0 as black and -1 as white

Every drawing operation is repeated three times, rotated 120°. The blunting of the "claws" is done with another circle. The inside "line cuts" are special-cased because I couldn't think of a more efficient way to get them in there. The "basic unit" defined in the specification is doubled here so I didn't have to use .5 in circles and int() all over the place to satisfy pygame.

Result for python3 -c 'from biohazard import *; f(500)':

Display output of this answer

  • 1
    \$\begingroup\$ Good job and welcome to CGCC! The description should say "Python 3 + pygame" when a non-builtin library is used. The input can be taken from standard input or as a function argument to avoid importing the sys module, which shortens the code (see rules). Also, this trick can be applied to avoid the need of importing math. \$\endgroup\$ – Joel Sep 8 '19 at 13:48
  • \$\begingroup\$ @Joel Thanks for the feedback! I included pygame in the header, and converted the code to a function. As for math, I refactored that to a list of coordinates; it was only 3 of them anyway. No (co)sine necessary. \$\endgroup\$ – marcelm Sep 8 '19 at 16:19
  • 1
    \$\begingroup\$ Applying the above-mentioned trick actually saves more bytes than putting all the numbers into the source code. \$\endgroup\$ – Joel Sep 8 '19 at 17:04
  • \$\begingroup\$ @Joel Thanks for the reminder; earlier I discarded that option because it seemed longer but it looks like I was wrong. It also allowed some more optimizations. \$\endgroup\$ – marcelm Sep 8 '19 at 18:52

Tcl/Tk - 557 bytes

set F #000
set B #F50
pack [canvas .c -bg $B]
rename expr e
rename foreach f
rename proc p
p R r {list [e $r*cos($::a)] [e $r*sin($::a)]}
p D {d r} {lassign [R $d] x y;list [e $x-$r] [e $y-$r] [e $x+$r] [e $y+$r]}
p C {d r c} {.c cr o {*}[D $d $r] -f $c -outline $c}
p L {p q w} {.c cr l {*}[R $p] {*}[R $q] -w [e $w] -f $::B}
p A {d r w c} {.c cr a {*}[D $d $r] -w [e $w] -star 0 -ex 359.9 -sty arc -outline $c}
f x {{C 11 15 $F} {C 15 10.5 $B} {L 0 5 1} {L 20 40 4} {C 0 3 $B} {A 0 11.75 3.5 $F} {A 15 10 1 $B}} {f a {2.62 4.72 6.81} $x}
.c move all 99 99

That version, however, is boring, since you get the same small-sized image no matter what. It does satisfy the OP conditions for displaying on-screen, however. Here is the uncompressed version with commentary and the ability to specify a size added in:

# Input: command line argument is the pixel width (same as the height) of the window to create
# For example:
#   wish a.tcl 500
set window_size $argv

set foreground_color #000
set background_color #F50
pack [canvas .c -bg $background_color -width $window_size -height $window_size]

# Helper procs to generate x,y coordinates
proc radius->x,y r {
  list [expr {$r*cos($::angle)}] [expr {$r*sin($::angle)}]

proc center_offset,radius->rectangle {offset r} {
  lassign [radius->x,y $offset] x y
  list [expr {$x-$r}] [expr {$y-$r}] [expr {$x+$r}] [expr {$y+$r}]

# Tk's canvas does not scale line widths, so we have to do that manually
# The $scale is a global variable for compressing the code text above
set scale [expr {$window_size*.016}]

# These three procs draw items in the canvas
proc circle {offset r color} {
  .c create oval {*}[center_offset,radius->rectangle $offset $r] -fill $color -outline $color
proc line {p q w} {
  .c create line {*}[radius->x,y $p] {*}[radius->x,y $q] -width [expr {$::scale*$w}] -fill $::background_color
proc annulus {offset r w color} {
  .c create arc {*}[center_offset,radius->rectangle $offset $r] -width [expr {$::scale*$w}] -start 0 -extent 359.9 -style arc -outline $color

# Our list of shapes to draw
#  circle  center_offset, radius,                   color
#  line    end_offset_1,  end_offset_2, line_width
#  annulus center_offset, radius,       line_width, color
foreach command {
  {circle  11 15        $foreground_color}
  {circle  15 10.5      $background_color}
  {line     0  5    1}
  {line    20 40    4}
  {circle   0  3        $background_color}
  {annulus  0 11.75 3.5 $foreground_color}
  {annulus 15 10    1   $background_color}
} {
  # Each command gets applied thrice, rotated $angle radians each time
  foreach angle {2.62 4.72 6.81} $command

.c scale all 0 0 $scale $scale
.c move all [expr {$window_size/2}] [expr {$window_size/2}]

# Some random convenience stuff for playing with it
bind . <Escape> exit
after 500 {focus -force .}

Sorry, no pictures (working off my phone today). Produces a black symbol on a biohazard orange background.


C (gcc) (MinGW), 557 530 524 522 bytes

-27 -6 bytes thanks to ceilingcat

Added compiler option -lm on TiO strictly to be able to show how it runs. Under MinGW this is not necessary.

Takes width of image as a command line argument. Outputs a 3-shade greyscale PGM file to STDOUT. The circle drawing function is slightly longer than it could be, to avoid dreadful runtime on even moderately sized images, the positioning/scaling of the symbol is not perfect, and I suspect shuffling the draw order somewhat might squeeze some more out of this, so there is room for improvement for sure.

Everything is drawn as circles. The rectangular cutouts are painted using the circle drawing function as a moving brush.

char*I;q,j=5,r,c;N(n){n="F=**(..*(C/)F<<*>FF)"[j*4+n]-40;}float d,b,m,x,y,V=2.0944;C(x,y,R,t,z)float x,y,R,t;{for(r=y<R?0:y-R;r<=y+R;r++)for(c=x-R;c<=x+R;c++)d=hypot(c-x,r-y),d<R&d>=R-t?I[r*q+c]=z:0;}main(i,v)int**v;{q=atoi(v[1]);b=q/104.;m=q/2.;for(I=memset(calloc(q,q+1),2,q*q);i=j--;)for(x=0;x<7;x+=V)C(m+cos(x)-N(0)*b*sin(x),m-N(0)*b*cos(x)+sin(x),N(1)*b,N(2)*b,N(3));for(;i<3;i++)for(j=m;j--;C(m-x,m-y,d,d=d>4*b&d<10*b?b:d>50*b?b*4:0,2))d=hypot(x=j*sin(x)-cos(x),y=j*cos(x=i*V)-sin(x));printf("P5 %d %d 2 %s",q,q,I);}

Try it online!

  • \$\begingroup\$ @ceilingcat Quite the improvement! \$\endgroup\$ – gastropner Nov 21 '19 at 18:00

Wolfram Language (Mathematica), 211 209 bytes


Here exported with the additional option PlotPoints -> 100 to make it look more accurate:

enter image description here


Scratch, 423 bytes

Try it online!

Surprisingly, Scratch beats more than 0 other langauges! Alternatively, 46 blocks.

define T(o
turn cw(o)degrees
define P(s
set pen size to(s
define (d)(r)(t)(c
set pen color to(c
pen down
pen up
when gf clicked
point in direction(0
erase all
pen down
pen down
pen up
go to x()y(



define T(o                Obligatory hat block
turn cw(o)degrees         Rotate clockwise a specified amount of degrees

define P(s                Obligatory hat block
set pen size to(s         Sets pen size to a specified amount

define (d)(r)(t)(c        d=distance, r=radius, t=thickness (of ring), c=color
set pen color to(c        Sets pen to a specified color
P(1                       Sets pen size to be 1 pixel in diameter
repeat(3                  Loops code for each circle
move(d)steps              Moves a specified distance away from the center
repeat(360                Loops code for each ray being drawn in a circle
move(r)steps              Moves to the inner edge of the ring, without applying pen
pen down                  Begins to apply pen
move(t)steps              Applies pen for the specified thickness of the ring
pen up                    Stops applying the pen
move(()-((r)+(t)))steps   Moves back to the center of the circle being drawn
T(1                       Rotates 1 degree clockwise
end                       Ends code to be  looped
go to x()y(               Moves to the center
T(120                     Rotates in preparation of next circle


when gf clicked        Initiates code
repeat(2               Loops code twice, skipping the need to move to the origin.
point in direction(0   Resets angle
erase all              Clears stage
(22)()(30)(            Draws 3 black circles 22 pixels from the center, with a radius of 30
(30)()(19)(#fff        Draws 3 white circles 30 pixels from the center, with a radius of 19
repeat(3               Loops code for each break to be made
P(2                    Sets pen size to 2 pixels in diameter
pen down               Applies pen
move(52)steps          Draws a white line from the center
P(8                    Sets pen size to 8 pixels in diameter
pen down               Applies pen, creating the gap in the outer rings
pen up                 Removes pen
go to x()y(            Moves to the origin
T(120                  Rotates 120 degrees clockwise
()(20)(7)(             Draws a black ring 7 pixels thick with an internal radius of 20 pixels
()()(6)(#fff           Draws a white circle with a 6 pixel radius
(30)(19)(2)(#fff       Draws 3 white rings 30 pixels from the center, 2 pixels thick, and an internal radius of 29 pixels

Your Answer

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

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