This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
Discussion thread for day 17 of the Advent of Code - https://adventofcode.com/2021/day/17
When in doubt brute force it out. I tried for 40min to learn the math with limited success.
Interesting to see the variety of possible velocities...
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.
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.
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.
In terms of the mechanics, a batch macro to pass each velocity in one by one.
And an iterative macro for calculating the points
https://github.com/dsmdavid/AdventCode2021
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!
Cheers!
NJ
This is brute forth... but my workflow finish around 30 seconds for Start1 and 2.
Git Hub
https://github.com/AkimasaKajitani/AdventOfCode/tree/main/2021
All Generate Row tool version.
Git Hub
https://github.com/AkimasaKajitani/AdventOfCode/tree/main/2021
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.