WeixiangYan/CodeTransOcean huggingface dataset:
Task: MD5




Go: package main

import (
    "crypto/md5"
    "fmt"
)

func main() {
    for _, p := range [][2]string{
        
        {"d41d8cd98f00b204e9800998ecf8427e", ""},
        {"0cc175b9c0f1b6a831c399e269772661", "a"},
        {"900150983cd24fb0d6963f7d28e17f72", "abc"},
        {"f96b697d7cb7938d525a2f31aaf161d0", "message digest"},
        {"c3fcd3d76192e4007dfb496cca67e13b", "abcdefghijklmnopqrstuvwxyz"},
        {"d174ab98d277d9f5a5611c2c9f419d9f",
            "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"},
        {"57edf4a22be3c955ac49da2e2107b67a", "12345678901234567890" +
            "123456789012345678901234567890123456789012345678901234567890"},
        
        {"e38ca1d920c4b8b8d3946b2c72f01680",
            "The quick brown fox jumped over the lazy dog's back"},
    } {
        validate(p[0], p[1])
    }
}

var h = md5.New()

func validate(check, s string) {
    h.Reset()
    h.Write([]byte(s))
    sum := fmt.Sprintf("%x", h.Sum(nil))
    if sum != check {
        fmt.Println("MD5 fail")
        fmt.Println("  for string,", s)
        fmt.Println("  expected:  ", check)
        fmt.Println("  got:       ", sum)
    }
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. MD5.
       AUTHOR.  Bill Gunshannon
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   Use the md5sum utility and pass the HASH back using
      **     a temp file.  Not elegant, but it works.
      ************************************************************
       
       
       ENVIRONMENT DIVISION.
       
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
            SELECT Tmp-MD5 ASSIGN TO "/tmp/MD5"
                 ORGANIZATION IS LINE SEQUENTIAL.


       DATA DIVISION.

       FILE SECTION.
       
       FD  Tmp-MD5
           DATA RECORD IS MD5-Rec.
       01  MD5-Rec       PIC X(32).

       
       WORKING-STORAGE SECTION.
       
       01 Eof                   PIC X     VALUE 'F'.
       01 Str1.
          05  Pre-cmd   PIC X(8)
              VALUE 'echo -n '.
          05  Str1-complete.
              10  Str1-Part1  PIC X(26)
                  VALUE  'The quick brown fox jumps'.
              10  Str1-Part2  PIC X(19)
                  VALUE  ' over the lazy dog'.
          05  Post-cmd    PIC X(20)
              VALUE  ' | md5sum > /tmp/MD5'.
       01  Str1-MD5          PIC X(32).
       
       
       PROCEDURE DIVISION.
       
       Main-Program.

           DISPLAY Str1-complete.
           PERFORM Get-MD5.
           DISPLAY Str1-MD5.

           STOP RUN.

       Get-MD5.
       
           CALL "SYSTEM" USING Str1.
           OPEN INPUT Tmp-MD5.
           READ Tmp-MD5 INTO Str1-MD5.
           CLOSE Tmp-MD5.
           CALL "CBL_DELETE_FILE" USING '/tmp/MD5'.
Task: MD5






PHP: $string = "The quick brown fox jumped over the lazy dog's back";
echo md5( $string );
Task: MD5






PHP: $string = "The quick brown fox jumped over the lazy dog's back";
echo md5( $string );






Ada: with Ada.Text_IO; use Ada.Text_IO;
with GNAT.MD5;

procedure MD5_Digest is
begin
   Put(GNAT.MD5.Digest("Foo bar baz"));
end MD5_Digest;
Task: MD5






PHP: $string = "The quick brown fox jumped over the lazy dog's back";
echo md5( $string );




COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. MD5.
       AUTHOR.  Bill Gunshannon
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   Use the md5sum utility and pass the HASH back using
      **     a temp file.  Not elegant, but it works.
      ************************************************************
       
       
       ENVIRONMENT DIVISION.
       
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
            SELECT Tmp-MD5 ASSIGN TO "/tmp/MD5"
                 ORGANIZATION IS LINE SEQUENTIAL.


       DATA DIVISION.

       FILE SECTION.
       
       FD  Tmp-MD5
           DATA RECORD IS MD5-Rec.
       01  MD5-Rec       PIC X(32).

       
       WORKING-STORAGE SECTION.
       
       01 Eof                   PIC X     VALUE 'F'.
       01 Str1.
          05  Pre-cmd   PIC X(8)
              VALUE 'echo -n '.
          05  Str1-complete.
              10  Str1-Part1  PIC X(26)
                  VALUE  'The quick brown fox jumps'.
              10  Str1-Part2  PIC X(19)
                  VALUE  ' over the lazy dog'.
          05  Post-cmd    PIC X(20)
              VALUE  ' | md5sum > /tmp/MD5'.
       01  Str1-MD5          PIC X(32).
       
       
       PROCEDURE DIVISION.
       
       Main-Program.

           DISPLAY Str1-complete.
           PERFORM Get-MD5.
           DISPLAY Str1-MD5.

           STOP RUN.

       Get-MD5.
       
           CALL "SYSTEM" USING Str1.
           OPEN INPUT Tmp-MD5.
           READ Tmp-MD5 INTO Str1-MD5.
           CLOSE Tmp-MD5.
           CALL "CBL_DELETE_FILE" USING '/tmp/MD5'.
Task: Yin and yang



C#:     public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Paint += Form1_Paint;
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            DrawTaijitu(g, new Point(50, 50), 200, true);
            DrawTaijitu(g, new Point(10, 10), 60, true);
        }

        private void DrawTaijitu(Graphics g, Point pt, int width, bool hasOutline)
        {
            g.FillPie(Brushes.Black, pt.X, pt.Y, width, width, 90, 180);
            g.FillPie(Brushes.White, pt.X, pt.Y, width, width, 270, 180);
            float headSize = Convert.ToSingle(width * 0.5);
            float headXPosition = Convert.ToSingle(pt.X + (width * 0.25));
            g.FillEllipse(Brushes.Black, headXPosition, Convert.ToSingle(pt.Y), headSize, headSize);
            g.FillEllipse(Brushes.White, headXPosition, Convert.ToSingle(pt.Y + (width * 0.5)), headSize, headSize);
            float headBlobSize = Convert.ToSingle(width * 0.125);
            float headBlobXPosition = Convert.ToSingle(pt.X + (width * 0.4375));
            g.FillEllipse(Brushes.White, headBlobXPosition, Convert.ToSingle(pt.Y + (width * 0.1875)), headBlobSize, headBlobSize);
            g.FillEllipse(Brushes.Black, headBlobXPosition, Convert.ToSingle(pt.Y + (width * 0.6875)), headBlobSize, headBlobSize);
            if (hasOutline) g.DrawEllipse(Pens.Black, pt.X, pt.Y, width, width);
        }
    }









Ada: with Glib; use Glib;
with Cairo; use Cairo;
with Cairo.Png; use Cairo.Png;
with Cairo.Image_Surface; use Cairo.Image_Surface;

procedure YinYang is
   subtype Dub is Glib.Gdouble;

   procedure Draw (C : Cairo_Context; x : Dub; y : Dub; r : Dub) is begin
      Arc (C, x, y, r + 1.0, 1.571, 7.854);
      Set_Source_Rgb (C, 0.0, 0.0, 0.0); Fill (C);
      Arc_Negative (C, x, y - r / 2.0, r / 2.0, 1.571, 4.712);
      Arc (C, x, y + r / 2.0, r / 2.0, 1.571, 4.712);
      Arc_Negative (C, x, y, r, 4.712, 1.571);
      Set_Source_Rgb (C, 1.0, 1.0, 1.0); Fill (C);
      Arc (C, x, y - r / 2.0, r / 5.0, 1.571, 7.854);
      Set_Source_Rgb (C, 0.0, 0.0, 0.0); Fill (C);
      Arc (C, x, y + r / 2.0, r / 5.0, 1.571, 7.854);
      Set_Source_Rgb (C, 1.0, 1.0, 1.0); Fill (C);
   end Draw;

   Surface : Cairo_Surface;
   Context : Cairo_Context;
   Status : Cairo_Status;
begin
   Surface := Create (Cairo_Format_ARGB32, 200, 200);
   Context := Create (Surface);
   Draw (Context, 120.0, 120.0, 75.0);
   Draw (Context, 35.0, 35.0, 30.0);
   Status := Write_To_Png (Surface, "YinYangAda.png");
   pragma Assert (Status = Cairo_Status_Success);
end YinYang;
Task: Yin and yang

C: #include <stdio.h>

void draw_yinyang(int trans, double scale)
{
	printf("<use xlink:href='#y' transform='translate(%d,%d) scale(%g)'/>",
		trans, trans, scale);
}

int main()
{	printf(
	"<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
	"<!DOCTYPE svg PUBLIC '-
	"	'http:
	"<svg xmlns='http:
	"	xmlns:xlink='http:
	"		width='30' height='30'>\n"
	"	<defs><g id='y'>\n"
	"		<circle cx='0' cy='0' r='200' stroke='black'\n"
	"			fill='white' stroke-width='1'/>\n"
	"		<path d='M0 -200 A 200 200 0 0 0 0 200\n"
	"			100 100 0 0 0 0 0 100 100 0 0 1 0 -200\n"
	"			z' fill='black'/>\n"
	"		<circle cx='0' cy='100' r='33' fill='white'/>\n"
	"		<circle cx='0' cy='-100' r='33' fill='black'/>\n"
	"	</g></defs>\n");
	draw_yinyang(20, .05);
	draw_yinyang(8, .02);
	printf("</svg>");
	return 0;
}











Ada: with Glib; use Glib;
with Cairo; use Cairo;
with Cairo.Png; use Cairo.Png;
with Cairo.Image_Surface; use Cairo.Image_Surface;

procedure YinYang is
   subtype Dub is Glib.Gdouble;

   procedure Draw (C : Cairo_Context; x : Dub; y : Dub; r : Dub) is begin
      Arc (C, x, y, r + 1.0, 1.571, 7.854);
      Set_Source_Rgb (C, 0.0, 0.0, 0.0); Fill (C);
      Arc_Negative (C, x, y - r / 2.0, r / 2.0, 1.571, 4.712);
      Arc (C, x, y + r / 2.0, r / 2.0, 1.571, 4.712);
      Arc_Negative (C, x, y, r, 4.712, 1.571);
      Set_Source_Rgb (C, 1.0, 1.0, 1.0); Fill (C);
      Arc (C, x, y - r / 2.0, r / 5.0, 1.571, 7.854);
      Set_Source_Rgb (C, 0.0, 0.0, 0.0); Fill (C);
      Arc (C, x, y + r / 2.0, r / 5.0, 1.571, 7.854);
      Set_Source_Rgb (C, 1.0, 1.0, 1.0); Fill (C);
   end Draw;

   Surface : Cairo_Surface;
   Context : Cairo_Context;
   Status : Cairo_Status;
begin
   Surface := Create (Cairo_Format_ARGB32, 200, 200);
   Context := Create (Surface);
   Draw (Context, 120.0, 120.0, 75.0);
   Draw (Context, 35.0, 35.0, 30.0);
   Status := Write_To_Png (Surface, "YinYangAda.png");
   pragma Assert (Status = Cairo_Status_Success);
end YinYang;
Task: Yin and yang


C++: #include <iostream>

bool circle(int x, int y, int c, int r) {
    return (r * r) >= ((x = x / 2) * x) + ((y = y - c) * y);
}

char pixel(int x, int y, int r) {
    if (circle(x, y, -r / 2, r / 6)) {
        return '#';
    }
    if (circle(x, y, r / 2, r / 6)) {
        return '.';
    }
    if (circle(x, y, -r / 2, r / 2)) {
        return '.';
    }
    if (circle(x, y, r / 2, r / 2)) {
        return '#';
    }
    if (circle(x, y, 0, r)) {
        if (x < 0) {
            return '.';
        } else {
            return '#';
        }
    }
    return ' ';
}

void yinYang(int r) {
    for (int y = -r; y <= r; y++) {
        for (int x = -2 * r; x <= 2 * r; x++) {
            std::cout << pixel(x, y, r);
        }
        std::cout << '\n';
    }
}

int main() {
    yinYang(18);
    return 0;
}










Ada: with Glib; use Glib;
with Cairo; use Cairo;
with Cairo.Png; use Cairo.Png;
with Cairo.Image_Surface; use Cairo.Image_Surface;

procedure YinYang is
   subtype Dub is Glib.Gdouble;

   procedure Draw (C : Cairo_Context; x : Dub; y : Dub; r : Dub) is begin
      Arc (C, x, y, r + 1.0, 1.571, 7.854);
      Set_Source_Rgb (C, 0.0, 0.0, 0.0); Fill (C);
      Arc_Negative (C, x, y - r / 2.0, r / 2.0, 1.571, 4.712);
      Arc (C, x, y + r / 2.0, r / 2.0, 1.571, 4.712);
      Arc_Negative (C, x, y, r, 4.712, 1.571);
      Set_Source_Rgb (C, 1.0, 1.0, 1.0); Fill (C);
      Arc (C, x, y - r / 2.0, r / 5.0, 1.571, 7.854);
      Set_Source_Rgb (C, 0.0, 0.0, 0.0); Fill (C);
      Arc (C, x, y + r / 2.0, r / 5.0, 1.571, 7.854);
      Set_Source_Rgb (C, 1.0, 1.0, 1.0); Fill (C);
   end Draw;

   Surface : Cairo_Surface;
   Context : Cairo_Context;
   Status : Cairo_Status;
begin
   Surface := Create (Cairo_Format_ARGB32, 200, 200);
   Context := Create (Surface);
   Draw (Context, 120.0, 120.0, 75.0);
   Draw (Context, 35.0, 35.0, 30.0);
   Status := Write_To_Png (Surface, "YinYangAda.png");
   pragma Assert (Status = Cairo_Status_Success);
end YinYang;
Task: Yin and yang




Go: package main

import (
    "fmt"
    "os"
    "text/template"
)

var tmpl = `<?xml version="1.0"?>
<svg xmlns="http:
    xmlns:xlink="http:
    width="210" height="150">
<symbol id="yy" viewBox="0 0 200 200">
<circle stroke="black" stroke-width="2" fill="white"
    cx="100" cy="100" r="99" />
<path fill="black"
    d="M100 100 a49 49 0 0 0 0 -98
    v-1 a99 99 0 0 1 0 198
    v-1 a49 49 0 0 1 0 -98" />
<circle fill="black" cx="100" cy="51" r="17" />
<circle fill="white" cx="100" cy="149" r="17" />
</symbol>
{{range .}}<use xlink:href="#yy"
    x="{{.X}}" y="{{.Y}}" width="{{.Sz}}" height="{{.Sz}}"/>
{{end}}</svg>
`


type xysz struct {
    X, Y, Sz int
}



var yys = []xysz{
    {20, 20, 100},
    {140, 30, 60},
}

func main() {
    xt := template.New("")
    template.Must(xt.Parse(tmpl))
    f, err := os.Create("yy.svg")
    if err != nil {
        fmt.Println(err)
        return
    }
    if err := xt.Execute(f, yys); err != nil {
        fmt.Println(err)
    }
    f.Close()
}








Ada: with Glib; use Glib;
with Cairo; use Cairo;
with Cairo.Png; use Cairo.Png;
with Cairo.Image_Surface; use Cairo.Image_Surface;

procedure YinYang is
   subtype Dub is Glib.Gdouble;

   procedure Draw (C : Cairo_Context; x : Dub; y : Dub; r : Dub) is begin
      Arc (C, x, y, r + 1.0, 1.571, 7.854);
      Set_Source_Rgb (C, 0.0, 0.0, 0.0); Fill (C);
      Arc_Negative (C, x, y - r / 2.0, r / 2.0, 1.571, 4.712);
      Arc (C, x, y + r / 2.0, r / 2.0, 1.571, 4.712);
      Arc_Negative (C, x, y, r, 4.712, 1.571);
      Set_Source_Rgb (C, 1.0, 1.0, 1.0); Fill (C);
      Arc (C, x, y - r / 2.0, r / 5.0, 1.571, 7.854);
      Set_Source_Rgb (C, 0.0, 0.0, 0.0); Fill (C);
      Arc (C, x, y + r / 2.0, r / 5.0, 1.571, 7.854);
      Set_Source_Rgb (C, 1.0, 1.0, 1.0); Fill (C);
   end Draw;

   Surface : Cairo_Surface;
   Context : Cairo_Context;
   Status : Cairo_Status;
begin
   Surface := Create (Cairo_Format_ARGB32, 200, 200);
   Context := Create (Surface);
   Draw (Context, 120.0, 120.0, 75.0);
   Draw (Context, 35.0, 35.0, 30.0);
   Status := Write_To_Png (Surface, "YinYangAda.png");
   pragma Assert (Status = Cairo_Status_Success);
end YinYang;
Task: Yin and yang







Python: import math
def yinyang(n=3):
	radii   = [i * n for i in (1, 3, 6)]
	ranges  = [list(range(-r, r+1)) for r in radii]
	squares = [[ (x,y) for x in rnge for y in rnge]
		   for rnge in ranges]
	circles = [[ (x,y) for x,y in sqrpoints
		     if math.hypot(x,y) <= radius ]
		   for sqrpoints, radius in zip(squares, radii)]
	m = {(x,y):' ' for x,y in squares[-1]}
	for x,y in circles[-1]:
		m[x,y] = '*'
	for x,y in circles[-1]:
		if x>0: m[(x,y)] = '·'
	for x,y in circles[-2]:
		m[(x,y+3*n)] = '*'
		m[(x,y-3*n)] = '·'
	for x,y in circles[-3]:
		m[(x,y+3*n)] = '·'
		m[(x,y-3*n)] = '*'
	return '\n'.join(''.join(m[(x,y)] for x in reversed(ranges[-1])) for y in ranges[-1])





Ada: with Glib; use Glib;
with Cairo; use Cairo;
with Cairo.Png; use Cairo.Png;
with Cairo.Image_Surface; use Cairo.Image_Surface;

procedure YinYang is
   subtype Dub is Glib.Gdouble;

   procedure Draw (C : Cairo_Context; x : Dub; y : Dub; r : Dub) is begin
      Arc (C, x, y, r + 1.0, 1.571, 7.854);
      Set_Source_Rgb (C, 0.0, 0.0, 0.0); Fill (C);
      Arc_Negative (C, x, y - r / 2.0, r / 2.0, 1.571, 4.712);
      Arc (C, x, y + r / 2.0, r / 2.0, 1.571, 4.712);
      Arc_Negative (C, x, y, r, 4.712, 1.571);
      Set_Source_Rgb (C, 1.0, 1.0, 1.0); Fill (C);
      Arc (C, x, y - r / 2.0, r / 5.0, 1.571, 7.854);
      Set_Source_Rgb (C, 0.0, 0.0, 0.0); Fill (C);
      Arc (C, x, y + r / 2.0, r / 5.0, 1.571, 7.854);
      Set_Source_Rgb (C, 1.0, 1.0, 1.0); Fill (C);
   end Draw;

   Surface : Cairo_Surface;
   Context : Cairo_Context;
   Status : Cairo_Status;
begin
   Surface := Create (Cairo_Format_ARGB32, 200, 200);
   Context := Create (Surface);
   Draw (Context, 120.0, 120.0, 75.0);
   Draw (Context, 35.0, 35.0, 30.0);
   Status := Write_To_Png (Surface, "YinYangAda.png");
   pragma Assert (Status = Cairo_Status_Success);
end YinYang;
Task: Yin and yang








VB: Private Sub yinyang(Top As Integer, Left As Integer, Size As Integer)
    ActiveSheet.Shapes.AddShape(msoShapeChord, Top, Left, Size, Size).Select
    With Selection.ShapeRange
        .Adjustments.Item(1) = 90
        .Fill.ForeColor.RGB = RGB(255, 255, 255)
        .Line.ForeColor.RGB = RGB(0, 0, 0)
    End With
    ActiveSheet.Shapes.AddShape(msoShapeChord, Top, Left, Size, Size).Select
    With Selection.ShapeRange
        .Adjustments.Item(1) = 90
        .IncrementRotation 180
        .Fill.ForeColor.RGB = RGB(0, 0, 0)
        .Line.ForeColor.RGB = RGB(0, 0, 0)
    End With
    ActiveSheet.Shapes.AddShape(msoShapeOval, Top + Size \ 4, Left, Size \ 2, Size \ 2).Select
    With Selection.ShapeRange
        .Fill.ForeColor.RGB = RGB(255, 255, 255)
        .Line.ForeColor.RGB = RGB(255, 255, 255)
    End With
    ActiveSheet.Shapes.AddShape(msoShapeOval, Top + Size \ 4, Left + Size \ 2, Size \ 2, Size \ 2).Select
    With Selection.ShapeRange
        .Fill.ForeColor.RGB = RGB(0, 0, 0)
        .Line.ForeColor.RGB = RGB(0, 0, 0)
    End With
    ActiveSheet.Shapes.AddShape(msoShapeOval, Top + 5 * Size \ 12, Left + Size \ 6, Size \ 6, Size \ 6).Select
    With Selection.ShapeRange
        .Fill.ForeColor.RGB = RGB(0, 0, 0)
        .Line.ForeColor.RGB = RGB(0, 0, 0)
    End With
    ActiveSheet.Shapes.AddShape(msoShapeOval, Top + 5 * Size \ 12, Left + 2 * Size \ 3, Size \ 6, Size \ 6).Select
    With Selection.ShapeRange
        .Fill.ForeColor.RGB = RGB(255, 255, 255)
        .Line.ForeColor.RGB = RGB(255, 255, 255)
    End With
    ActiveSheet.Shapes.SelectAll
    Selection.ShapeRange.Group
End Sub
Public Sub draw()
    yinyang 200, 100, 100
    yinyang 275, 175, 25
End Sub




Ada: with Glib; use Glib;
with Cairo; use Cairo;
with Cairo.Png; use Cairo.Png;
with Cairo.Image_Surface; use Cairo.Image_Surface;

procedure YinYang is
   subtype Dub is Glib.Gdouble;

   procedure Draw (C : Cairo_Context; x : Dub; y : Dub; r : Dub) is begin
      Arc (C, x, y, r + 1.0, 1.571, 7.854);
      Set_Source_Rgb (C, 0.0, 0.0, 0.0); Fill (C);
      Arc_Negative (C, x, y - r / 2.0, r / 2.0, 1.571, 4.712);
      Arc (C, x, y + r / 2.0, r / 2.0, 1.571, 4.712);
      Arc_Negative (C, x, y, r, 4.712, 1.571);
      Set_Source_Rgb (C, 1.0, 1.0, 1.0); Fill (C);
      Arc (C, x, y - r / 2.0, r / 5.0, 1.571, 7.854);
      Set_Source_Rgb (C, 0.0, 0.0, 0.0); Fill (C);
      Arc (C, x, y + r / 2.0, r / 5.0, 1.571, 7.854);
      Set_Source_Rgb (C, 1.0, 1.0, 1.0); Fill (C);
   end Draw;

   Surface : Cairo_Surface;
   Context : Cairo_Context;
   Status : Cairo_Status;
begin
   Surface := Create (Cairo_Format_ARGB32, 200, 200);
   Context := Create (Surface);
   Draw (Context, 120.0, 120.0, 75.0);
   Draw (Context, 35.0, 35.0, 30.0);
   Status := Write_To_Png (Surface, "YinYangAda.png");
   pragma Assert (Status = Cairo_Status_Success);
end YinYang;
Task: Yin and yang

C: #include <stdio.h>

void draw_yinyang(int trans, double scale)
{
	printf("<use xlink:href='#y' transform='translate(%d,%d) scale(%g)'/>",
		trans, trans, scale);
}

int main()
{	printf(
	"<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"
	"<!DOCTYPE svg PUBLIC '-
	"	'http:
	"<svg xmlns='http:
	"	xmlns:xlink='http:
	"		width='30' height='30'>\n"
	"	<defs><g id='y'>\n"
	"		<circle cx='0' cy='0' r='200' stroke='black'\n"
	"			fill='white' stroke-width='1'/>\n"
	"		<path d='M0 -200 A 200 200 0 0 0 0 200\n"
	"			100 100 0 0 0 0 0 100 100 0 0 1 0 -200\n"
	"			z' fill='black'/>\n"
	"		<circle cx='0' cy='100' r='33' fill='white'/>\n"
	"		<circle cx='0' cy='-100' r='33' fill='black'/>\n"
	"	</g></defs>\n");
	draw_yinyang(20, .05);
	draw_yinyang(8, .02);
	printf("</svg>");
	return 0;
}
Task: Yin and yang



C#:     public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Paint += Form1_Paint;
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            DrawTaijitu(g, new Point(50, 50), 200, true);
            DrawTaijitu(g, new Point(10, 10), 60, true);
        }

        private void DrawTaijitu(Graphics g, Point pt, int width, bool hasOutline)
        {
            g.FillPie(Brushes.Black, pt.X, pt.Y, width, width, 90, 180);
            g.FillPie(Brushes.White, pt.X, pt.Y, width, width, 270, 180);
            float headSize = Convert.ToSingle(width * 0.5);
            float headXPosition = Convert.ToSingle(pt.X + (width * 0.25));
            g.FillEllipse(Brushes.Black, headXPosition, Convert.ToSingle(pt.Y), headSize, headSize);
            g.FillEllipse(Brushes.White, headXPosition, Convert.ToSingle(pt.Y + (width * 0.5)), headSize, headSize);
            float headBlobSize = Convert.ToSingle(width * 0.125);
            float headBlobXPosition = Convert.ToSingle(pt.X + (width * 0.4375));
            g.FillEllipse(Brushes.White, headBlobXPosition, Convert.ToSingle(pt.Y + (width * 0.1875)), headBlobSize, headBlobSize);
            g.FillEllipse(Brushes.Black, headBlobXPosition, Convert.ToSingle(pt.Y + (width * 0.6875)), headBlobSize, headBlobSize);
            if (hasOutline) g.DrawEllipse(Pens.Black, pt.X, pt.Y, width, width);
        }
    }
Task: Yin and yang


C++: #include <iostream>

bool circle(int x, int y, int c, int r) {
    return (r * r) >= ((x = x / 2) * x) + ((y = y - c) * y);
}

char pixel(int x, int y, int r) {
    if (circle(x, y, -r / 2, r / 6)) {
        return '#';
    }
    if (circle(x, y, r / 2, r / 6)) {
        return '.';
    }
    if (circle(x, y, -r / 2, r / 2)) {
        return '.';
    }
    if (circle(x, y, r / 2, r / 2)) {
        return '#';
    }
    if (circle(x, y, 0, r)) {
        if (x < 0) {
            return '.';
        } else {
            return '#';
        }
    }
    return ' ';
}

void yinYang(int r) {
    for (int y = -r; y <= r; y++) {
        for (int x = -2 * r; x <= 2 * r; x++) {
            std::cout << pixel(x, y, r);
        }
        std::cout << '\n';
    }
}

int main() {
    yinYang(18);
    return 0;
}
Task: Yin and yang





Java: package org.rosettacode.yinandyang;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class YinYangGenerator
{
    private final int size;

    public YinYangGenerator(final int size)
    {
        this.size = size;
    }

    
    public void drawYinYang(final Graphics graphics)
    {
        
        final Color colorSave = graphics.getColor();

        graphics.setColor(Color.WHITE);
        
        graphics.fillOval(0, 0, size-1, size-1);
        
        graphics.setColor(Color.BLACK);
        
        graphics.fillArc(0, 0, size-1, size-1, 270, 180);
        graphics.fillOval(size/4, size/2, size/2, size/2);
        
        graphics.setColor(Color.WHITE);
        graphics.fillOval(size/4, 0, size/2, size/2);
        graphics.fillOval(7*size/16, 11*size/16, size/8, size/8);

        graphics.setColor(Color.BLACK);
        graphics.fillOval(7*size/16, 3*size/16, size/8, size/8);
        
        graphics.drawOval(0, 0, size-1, size-1);
        
        
        graphics.setColor(colorSave);
    }

    
    public Image createImage(final Color bg)
    {
        
        final BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB);
        
        
        
        final Graphics graphics = image.getGraphics();
        
        graphics.setColor(bg);
        graphics.fillRect(0,0,size,size);
        drawYinYang(graphics);
        return image;
    }

    public static void main(final String args[])
    {
        final int size = Integer.parseInt(args[0]);
        final YinYangGenerator generator = new YinYangGenerator(size);

        final JFrame frame = new JFrame("Yin Yang Generator");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        final Image yinYang = generator.createImage(frame.getBackground());
        
        frame.add(new JLabel(new ImageIcon(yinYang)));
        frame.pack();
        frame.setVisible(true);
    }
}