General Discussions

Discuss a wide range of topics! Questions about the Alteryx Platform should be directed to the appropriate Product discussion forum.

Advent of Code 2021 Day 17 (BaseA Style)

jdunkerley79
16 - Nebula
16 - Nebula

Discussion thread for day 17 of the Advent of Code - https://adventofcode.com/2021/day/17

11 REPLIES 11
bflick
7 - Meteor

When in doubt brute force it out. I tried for 40min to learn the math with limited success.

Spoiler
Challenge 1 math helped with narrowing the X range to where X velocity reached 0 within the target range. Challenge 2 just went with a brute force using generated rows. Ended up generating ~2bil rows (65GB of data) and letting it run for 30 min. An iterative macro probably would have been the smarter choice. Could have just counted every time there was a match instead of storing all that memory.
bflick_0-1639724396674.png

 

clmc9601
12 - Quasar

Interesting to see the variety of possible velocities...

Spoiler
I manually tinkered with the starting velocity ranges in the Generate Rows tools. I was surprised by some of the options that worked. 

Since the latest valid velocities came from iterations 250 ish, I made the assumption (validly, for my puzzle input) that those still running after 1000 iterations would not make it into the target. These rows were probably still iterating because I set my possible y velocities too high.

Graphing the target helped me estimate the best starting velocitiesGraphing the target helped me estimate the best starting velocitiesWorkflowWorkflowIterative macroIterative macro
LiuZhang
8 - Asteroid
Spoiler
workflowworkflowInnerInnerOuterOuter

Finally a more relaxed one.

Part 1 can be done use the knowledge for projectile motion, mins y for me is -248, so the downward max velocity should be -247 at returning to y = 0. Then just a arithmetic sum to go up to find max height.

Part 2 is brute force to run through all combination. Inner macro calculates the trajectory for a given starting velocity up to boundary condition. Then outer macro filter the ones reaches the target. ~ 8mins runtime.

cgoodman3
13 - Pulsar
13 - Pulsar

Nice to have an easier day following some recent tougher days.

 

Got a solution but not super keen on it as it relies on hardcoding values.

 

Spoiler
Main workflow
cgoodman3_0-1639780742598.png

I used generate rows, for positive y velocities I was able to easily extend the input from part 1, as only x velocities in the range 11 : 14 were possible, then for the negative y velocities knew you could get direct hits with the the velocities matching the x,y position, so it was a case of working back from there and finding the valid rectangles that worked. I was able to work out that there wasn't going to be anything in a particular range so was able to narrow down significantly the number of velocities to try. I could have worked out what would be valid but it was quicker just to leave the workflow running on the reduced set. Converting the velocities to x,y spatial points and you get a nice plot of all the possible valid points after 1 iteration.

cgoodman3_1-1639781083645.png

In terms of the mechanics, a batch macro to pass each velocity in one by one. 

cgoodman3_2-1639781169526.png


And an iterative macro for calculating the points

cgoodman3_3-1639781217545.png

 

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
dsmdavid
11 - Bolide

 

Spoiler
Took quite some time with pen and paper to understand the going up and down (and finding the n(n+1)/2 sequence again). dsmdavid_0-1639782499024.pngThe iterative could be replaced with a generate rows, but didn't think it's worth it as it takes just 2 sec to run.
The limits for the rows --
X: initial velocity must be at least 1 --otherwise the probe just drops--**, and at most Xmax;
Y: initial velocity must be at least ymin (and it reaches to the bottom of the target area in 1 step) or at most -ymin (and it goes up, up, up, down, down, down, and reaches the bottom of the target area one turn after going through y=0)
**could be better narrowed down based on the minimum speed needed to reach Xmin and stop there, but it just adds a few rows.

Then just update every iteration the velocity and position, discard anything that is outside of viable trajectories (e.g. too far away already), output anything inside the target area and keep running the rest
dsmdavid_1-1639782526033.png

 

 

https://github.com/dsmdavid/AdventCode2021

 

NicoleJohnson
14 - Magnetar
14 - Magnetar

Trying to get back in the game! A few days behind, but this one was fun, and quite pleased to find a macro-less way to do this! Runs in 1 second too!

 

Spoiler
Generate Rows tool is the true hero in this one. 
NicoleJohnson_0-1639792482910.png

 

Cheers!

NJ

AkimasaKajitani
15 - Aurora

This is brute forth... but my workflow finish around 30 seconds for Start1 and 2.

 

Spoiler
AkimasaKajitani_0-1639812534906.png

 

Git Hub

https://github.com/AkimasaKajitani/AdventOfCode/tree/main/2021

AkimasaKajitani
15 - Aurora

All Generate Row tool version.

 

Spoiler
Day17_type2.yxmd

It works efficiently because the Generate Row tool makes less records than previous workflow. So it takes a few seconds to finish.

AkimasaKajitani_0-1639815632089.png

 

Git Hub

https://github.com/AkimasaKajitani/AdventOfCode/tree/main/2021

estherb47
15 - Aurora
15 - Aurora

Mine is not efficient in any way, but I got to the answers (and solved parts 1 and 2 with the same workflow). If I have the energy, I'd like to make it run in under 5 minutes, but I've got too many rows generating at the moment.