How to resolve the algorithm Sierpinski triangle/Graphical step by step in the Icon and Unicon programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sierpinski triangle/Graphical step by step in the Icon and Unicon programming language
Table of Contents
Problem Statement
Produce a graphical representation of a Sierpinski triangle of order N in any orientation.
An example of Sierpinski's triangle (order = 8) looks like this:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sierpinski triangle/Graphical step by step in the Icon and Unicon programming language
Source code in the icon programming language
link wopen
procedure main(A)
local width, margin, x, y
width := 2 ^ (order := (0 < integer(\A[1])) | 8)
wsize := width + 2 * (margin := 30 )
WOpen("label=Sierpinski", "size="||wsize||","||wsize) |
stop("*** cannot open window")
every y := 0 to width - 1 do
every x := 0 to width - 1 do
if iand(x, y) = 0 then DrawPoint(x + margin, y + margin)
Event()
end
You may also check:How to resolve the algorithm Loops/For step by step in the Retro programming language
You may also check:How to resolve the algorithm Map range step by step in the Wren programming language
You may also check:How to resolve the algorithm Sudoku step by step in the Rust programming language
You may also check:How to resolve the algorithm Ackermann function step by step in the NetRexx programming language
You may also check:How to resolve the algorithm Leap year step by step in the Oforth programming language