How to resolve the algorithm Yin and yang step by step in the Draco programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Yin and yang step by step in the Draco programming language

Table of Contents

Problem Statement

One well-known symbol of the philosophy of duality known as yin and yang is the taijitu.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Yin and yang step by step in the Draco programming language

Source code in the draco programming language

proc circle(int x, c, y, r) bool:
    r*r >= (x/2)*(x/2) + (y-c)*(y-c)
corp

proc pixel(int x, y, r) char:
    if   circle(x, y, -r/2, r/6) then '\#'
    elif circle(x, y,  r/2, r/6) then '.'
    elif circle(x, y, -r/2, r/2) then '.'
    elif circle(x, y,  r/2, r/2) then '\#'
    elif circle(x, y, 0, r) then
        if x<0 then '.' else '\#' fi
    else ' '
    fi
corp

proc yinyang(int r) void:
    int x, y;
    for y from -r upto r do
        for x from -2*r upto 2*r do
            write(pixel(x, y, r))
        od;
        writeln()
    od
corp

proc main() void:
    yinyang(4);
    yinyang(8)
corp

  

You may also check:How to resolve the algorithm Perfect numbers step by step in the Lingo programming language
You may also check:How to resolve the algorithm Hello world/Newbie step by step in the AWK programming language
You may also check:How to resolve the algorithm Collections step by step in the Elena programming language
You may also check:How to resolve the algorithm String concatenation step by step in the Apex programming language
You may also check:How to resolve the algorithm Tarjan step by step in the Raku programming language