General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2023 Day 18 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

Discussion thread for day 18 of the Advent of Code - https://adventofcode.com/2023/day/18

17 REPLIES 17
Qiu
21 - Polaris
21 - Polaris

@Pang_Hee_Choy @phottovy 
I was looking at the Shoelace formula and the Pick's theorem seems to be more easier.
It turns out to be mathmatical problem. 😂

DaisukeTsuchiya
13 - Pulsar

I try to find the calculation method using excel but finally followed other's idea.

Spoiler
For P2, I draw the figure and tried to calculate manually. The results of sample can be matched but I stopped to develop WF then go to easier method.

<Manual Calculation Trial in Excel >

Spoiler
スクリーンショット 2023-12-19 193218.png
<WF : Development of WF in bottom container was stopped then switched to easier method>

Spoiler
スクリーンショット 2023-12-19 204247.png


  

 

ApekshaSharma
6 - Meteoroid

 

Spoiler
I will suck at explaining this, but here is my attempt.

Also, I am managing with a small laptop screen right now - not able to get very clear screenshots of the workflow-so skipped it.

P2 Approach: 

Step 1: Split the digging input into two streams -  i. Up & Down (Row Movement) ii. Left & Right (Column Movement)
Step 2: Retaining the digging order, generate next (Row,Column) point using Multi Row Formula for each stream.
Step 3: Union all the generated points together and order them by digging order. Using multi-row formula, populate the next (Row,Column) Point. The next point for the last point will be the first point. 
Step 4: Using the current and next point, generate all the points that make up the perimeter. (I split the input into four streams based on the direction of digging and then used multi-row)
Step 5:  After all the perimeter points were generated, I built a sequence polygon using poly-build tool.

Below is the main logic :

Screenshot 2023-12-23 143856.png
 
Step 6: I first ordered all the perimeter points by Row ID Asc, Col ID Asc. Like 1,1; 1,2; 1,5; 1,6; 2,1; 2,6; etc.......
Step 7: Then for each column within a row, I determined the next available column (within the same row) - consider only perimeter points. Like 1,1-1,2; 1,2-1,5; 1,5-1,6
Step 8: Count points between each pair of perimeter points created in the previous step - For 1,1-1,2; 1,2-1,5; 1,5-1,6, it would be 0,2,0
Step 9: Using the first perimeter point from each pair calculate the immediate next point on the right - Example - 1,1 - 1,2; 1,2 - 1,3
Step 10: Now using spatial match check whether the newly generated point lies in the polygon area using spatial match, if it does the counted points between the pair of perimeter points should count towards the total area otherwise, they should be discarded.
Step 11: To the above, add the total count of the perimeter points and that's the total area! 
Day 18 .png






 

 

estherb47
15 - Aurora
15 - Aurora

Well, my first thought was "this looks a lot like day 10", so started in with a spatial approach. 

 

While this worked, it took about 2.5 minutes to run. I did learn fun things about generating integer points and getting them to intersect (have them come from the same stream of data!). But knew this wouldn't be scalable for part 2

 

Read through solution descriptions, and found the shoelace method. 

 

Runs in 0.5 seconds

 

Spoiler
Don't forget to account for the area of the path itself!
AkimasaKajitani
17 - Castor
17 - Castor

Part 1 : I use spatial tools.

Part 2 : The shoelace formula is needed.

 

Spoiler
Part 1 macro to get the route.

AoC_2023_18_05.png

And then, I use the spatial tools.

AoC_2023_18_13.png

Part 2, I use shoelace formula. But it can't be not applicable as is.

First, we need to remake the route data. HexToNumber function is needed to do it. And I prepare that data for shoelace formula.
AoC_2023_18_06.png
Note that we can not get the answer only the shoelace formula. We need to consider the points on the outer circumsference. In this case we can use the length of outer circumsference. The final formula is as follows.

Spoiler
Area + perimeter length /2 +1

This is the final workflow.

AoC_2023_18_07.png



 

Tokimatsu
12 - Quasar

I solved P1 and P2 without any hints. I learned the shoelace formula here. It is very smart.

Spoiler
スクリーンショット 2024-01-07 181027.png
Carolyn
9 - Comet

@phottovy - Thanks for sharing. I was so close but forgot to add in the perimeter/steps around the outside - thank you as usual for unsticking me :) 

Pang_Hee_Choy
12 - Quasar

post workflow. 

Labels