Weekly Challenges

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #420: The Sierpinski Triangle

AYXAcademy
Alteryx
Alteryx

Maveryx_WC_Banner.png

Hi Maveryx,

 

A solution to last week’s challenge can be found here. 

 

This week, we are diving deep into the realms of Math and Spatial tools by tackling the creation of Sierpinski’s triangle fractal. This challenge, designed by Roland van Leeuwen @RWvanLeeuwen, is an Expert-level task. If you are preparing for certification and plan to attempt an exam during Inspire, it is an excellent opportunity to hone your skills. Thank you, Roland, for crafting this challenge!

 

What is a Sierpinski triangle?

A Sierpinski triangle is a fractal shape composed of smaller triangles, each a scaled-down replica of the whole. It is created by repeatedly dividing an equilateral triangle into smaller triangles and removing the middle triangle at each iteration. This process results in a geometric pattern that exhibits self-similarity at different scales, forming a visually striking and intricate triangle-based fractal.

(This definition is sourced from https://en.wikipedia.org/wiki/Sierpi%C5%84ski_triangle.)

 

The provided input consists of the of latitude, longitude, and corners a, b, and c.  (The corners are used to determine each point of the triangle.) Your output triangle will look like this:

 

AYXAcademy_0-1711976537546.png

For this challenge, we are providing additional guidance to simplify the tasks and help you build your Sierpinski’s triangle.

 

To construct a fractal triangle, follow these steps:

  1. Find the corners (points a, b, and c), and any random point within the triangle as a starting point.
  2. Select one of the corners of the triangle and form a line from the point to the corner.
  3. The center point of the line created is the one we will iterate with.
  4. Using the center point of the created line, pick another random corner, draw a line, and find its center.
  5. Repeat steps 2 to 4 for 100 iterations.
  6. Map all points as green diamonds and the first random centroid as black.

 

 

 

By repeating these steps, a fractal should appear in the shape of Sierpinski's triangle!

 

If you need a refresher on how to build an iterative macro or create spatial objects, review these lessons in Academy to gear up:

 

 

Good luck!

 

AYX-Maveryx_Micro Identity-Maveryx Academy_wordmark.png

Kenda
16 - Nebula
16 - Nebula

This definitely seems like a @patrick_digan math problem

 

 

Spoiler
I went for 10k iterations and triangle shapes rather than diamonds
image.png
mmontgomery
11 - Bolide

Oof, this was a doozy. More in spoiler

Spoiler
It took me a while to understand what to do. I tweaked step 4 by taking the centroid of a random point and a random vertex. The new centroid would be my starting point, which would then map to a random vertex and so on.

Also, I iterated it 2000 times for a more holistic picture.
420_Base.png420_macro.png
ScottLewis
8 - Asteroid

That was fascinating. Having a hard time with why the algorithm works from any point but it sure does.
Needed a lot more than 100 iterations to get something filled out. Wonder if that meant 100, from each existing point each time.

I just kicked it up to 10k and the pattern emerges.

 

 

gawa
15 - Aurora
15 - Aurora

I like math, I like this challenge.

When it comes to a challenge associated with Iteration Macro, it's very quiet here. It implies that Iterative operation in Alteryx would be one of the hurdle for the most users.

Spoiler
I could see the challenging tasks this week. First, we need to create Iterative Macro. Second, we need to use Spatial functions in Formula tool.  
To create a random point, ST_RandomPoint([obj]) is very handy.

image.png
Some observation:
(1) We need at least 1,000 iterations to get a vivid view, we are instructed to go with 100 iterations though. If your computer allows, go with 100k.

100
image.png

1k
image.png
10k
image.png

(2) Point created during the first 2 iterations sometimes fall outside the triangle(sometime not). I omitted the record from first 2 iterations. 
balajilolla2
8 - Asteroid
Spoiler
Solution Attached

Screenshot 2024-04-01 205741.jpg
Qiu
20 - Arcturus
20 - Arcturus

Math is really magical.

Spoiler
challenge_420-1.PNG
100 Iterations
challenge_420-A.PNG
30K iterations
challenge_420-B.PNG
JamesCharnley
13 - Pulsar

Great challenge! I posted a similar challenge before on Databasyx.com so I've gone a bit rogue and have a couple of other ways to create the Sierpinski triangle in Alteryx!

 

One way is similar to this challenge with using midpoints but cutting out shapes instead using spatial process. The other is to colour in every even number in a Pascal's Triangle!

 

Edit: Pictures in below post. Failed to upload and couldn't edit them in!

JamesCharnley
13 - Pulsar
Spoiler
image.pngimage.pngimage.png

Apologies for double post but pictures failed to upload in my previous post and can't edit them in still!

RolandSchubert
16 - Nebula
16 - Nebula
Spoiler
420.jpg