We've recently made an accessibility improvement to the community and therefore posts without any content are no longer allowed. Please use the spoiler feature or add a short message in the message body in order to submit your weekly challenge.
alteryx Community

# Weekly Challenge

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

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

We're actively looking for ideas on how to improve Weekly Challenges and would love to hear what you think!

Submit Feedback

## Challenge #161: Triangles, Triangles, Triangles

Alteryx Alumni (Retired)
The idea of the challenge is simple, but it could be a little trick to execute!

Provided are a set of coordinates. With this set of triangles, you must create triangles. Each triangular spatial object must have exactly 3 non-collinear points. With this data set, you should create 516 unique triangles! How many of the 516 can you get?

This week's challenge was contributed by @CharlieS !

17 - Castor

Fun challenge @CharlieS

Spoiler
While I naturally reach for the spatial tools, the formula tools can accomplish the same tasks without transposing the data.
14 - Magnetar

Fun challenge!  Last filter needed to match solution, but shouldn't tiny triangles still count?  Investigation of original data indicates these are non-linear points (Thank you Mr. Coss - High School Geometry Teacher)

Spoiler

17 - Castor

I'm delighted that I could contribute to the awesome-ness that is the Weekly Challenges! I originally designed this with several sub-challenges if you want more:

- Draw a triangle using Spatial tools

- Draw a triangle without using Spatial tools

- Draw multiple triangles using only a single tool

- Draw multiple triangles using an iterative macro

- Draw all 516 unique triangles

A note on the "valid" solutions: due to how the points were drawn, it is possible to produce some very thin triangles that would be collinear if a grid was drawn on a Cartesian plane. Rather than adjusting the points, I was curious to see different approaches to handing these scenarios.

17 - Castor

Challenge #161, done.

Spoiler

I also removed the tiny triangles to get to the final answer - (unsure why they don't count)

Cheers,

Alteryx Alumni (Retired)

Fun challenge!  Thanks @CharlieS

Spoiler
13 - Pulsar

Fun challenge! I had to look up (as I couldn't remember back to high school trigonometry how to determine if 3 points were collinear.

Spoiler
After doing some digging (looking at 3 points that are seemingly a straight line), I understood why I couldn't use 0 as the collinearity check. Some of the areas are basically 0, but are not really triangles as they appear to be lines on the plane.
14 - Magnetar

Fun challenge, I had troubles for the final filter :)

16 - Nebula

Interesting. Final filter was a challenge

Spoiler

First tried to filter triangles using ST_DIMENSION (should return 1 for lines)
ACE Emeritus

OK so I got a bit hung up on the definition of "Non-Collinear", so my workflow actually has 2 solutions - one that gets 516 unique triangles (not the most efficient solution compared to others, but logically it got me there, and I feel like my high school math teacher wouldn't have been mortified, so I'm okay with it)... and then an alternate solution that I feel better matches the intention that all triangles be "non-collinear", which I defined to mean that there could be no point in the triangle that was at the same latitude or longitude plane as any other point in that triangle. Results in far fewer triangles (essentially, any triangle with a straight vertical or horizontal side is eliminated by this method).

Either way, super fun challenge @CharlieS!

Spoiler
Method #1: Create 516 unique triangles... realized after looking at a few other solutions that the Unique tool would have greatly simplified this, but it got me there eventually (basically reordered the points in ascending RecordID order and then grouped them to eliminate duplicates, achieving the same effect... with way too many tools haha).

Method #2: Create only triangles that do contain any points that are on the same plane (latitude or longitude). Again, a bit of a roundabout way to get there (once again finding an obscure reason to use one of my hidden favorite tools, Make Columns!)... but conceptually this one was actually easier for me to wrap my head around. And since I cheated a little by borrowing the Unique tool from other solutions as my method to get rid of duplicates, I opted to not use any Spatial tools for this method, using the Spatial formulas instead. BONUS: The resulting picture of triangles with this method is quite pretty! :)

Cheers,

NJ