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

Published on 12 May 2024 09:40 PM
#J

How to resolve the algorithm Yin and yang step by step in the J 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 J programming language

Source code in the j programming language

yinyang=:3 :0
  radii=. y*1 3 6
  ranges=. i:each radii
  squares=. ,"0/~each ranges
  circles=. radii ([ >: +/"1&.:*:@])each squares
  cInds=. ({:radii) +each circles #&(,/)each squares

  M=. ' *.' {~  circles (*  1 + 0 >: {:"1)&(_1&{::) squares
  offset=. 3*y,0
  M=. '*' ((_2 {:: cInds) <@:+"1 offset)} M
  M=. '.' ((_2 {:: cInds) <@:-"1 offset)} M
  M=. '.' ((_3 {:: cInds) <@:+"1 offset)} M
  M=. '*' ((_3 {:: cInds) <@:-"1 offset)} M
)


   yinyang 1
      .      
   ......*   
  ....*..**  
 ....***..** 
 .....*..*** 
 ........*** 
.......******
 ...******** 
 ...**.***** 
 ..**...**** 
  ..**.****  
   .******   
      *      
   yinyang 2
            .            
        ........*        
      ...........**      
     .............**     
    ........*.....***    
   ........***....****   
  ........*****....****  
  .........***....*****  
 ...........*.....****** 
 .................****** 
 ................******* 
 ...............******** 
.............************
 ........*************** 
 .......**************** 
 ......***************** 
 ......*****.*********** 
  .....****...*********  
  ....****.....********  
   ....****...********   
    ...*****.********    
     ..*************     
      ..***********      
        .********        
            *


  

You may also check:How to resolve the algorithm Least common multiple step by step in the Picat programming language
You may also check:How to resolve the algorithm System time step by step in the Oz programming language
You may also check:How to resolve the algorithm Mandelbrot set step by step in the Haskell programming language
You may also check:How to resolve the algorithm Draw a cuboid step by step in the C programming language
You may also check:How to resolve the algorithm Summarize and say sequence step by step in the Ruby programming language