How to resolve the algorithm Sierpinski pentagon step by step in the zkl programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sierpinski pentagon step by step in the zkl programming language
Table of Contents
Problem Statement
Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sierpinski pentagon step by step in the zkl programming language
Source code in the zkl programming language
const order=5, sides=5, dim=250, scaleFactor=((3.0 - (5.0).pow(0.5))/2);
const tau=(0.0).pi*2; // 2*pi*r
orders:=order.pump(List,fcn(n){ (1.0 - scaleFactor)*dim*scaleFactor.pow(n) });
println(
#<<<
0'|
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
"); // 3,131 lines
fcn pgon(vertices){ // eg ( ((250,0),(248.595,1.93317),...), len 5
0'| |.fmt(
vertices.pump(String,fcn(v){ "%.3f %.3f ".fmt(v.xplode()) }) )
}
You may also check:How to resolve the algorithm Bell numbers step by step in the Lua programming language
You may also check:How to resolve the algorithm Greatest subsequential sum step by step in the Crystal programming language
You may also check:How to resolve the algorithm Show ASCII table step by step in the Nanoquery programming language
You may also check:How to resolve the algorithm Show the epoch step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Define a primitive data type step by step in the UNIX Shell programming language