Advent of Code 2021 Day 7 (BaseA Style)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
First thoughts were "let's think this through, surely there's some analytical way to solve it", second thoughts were, "nah, brute force!"... Eventually went back to the thinking board and got somewhere similar to @patrick_digan
I was beyond my breadth minimising the function for part 2, so started with the mean, thinking of going a binary search if that didn't work. Then it worked...
I've now seen the Reddit thread, but the explanations go partially over my head (good effort on the paper though 😁)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Here sharing but really here to find a better solution. Did anyone use an optimization algorithm, not just every position?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
finally got it...
Anyone figured out Part 2 without generating rows? I mean, I'm pretty sure it'd work taking account of the mean and the Std. Dev. or some sort of normalization, but couldn't figure it out myself (always too high on the score).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Variations on a theme, and took a somewhat brute force approach, and a very mathematical one.
To optimize this, I wanted to eliminate duplicate numbers for the Append fields, and also created a "count how many times each number appears in the list field to be used later.
Once all of the possible horizontal positions were aligned with each unique starting number, I calculated the number of steps (absolute value of the original number - the horizontal position)
For part 1, a summarize tool to add up the total number of steps per horizontal position per unique number. Take the results, multiply each by the number of times each number appears in the data set, summarize again for the total steps per horizontal position and sort ascending
For part 2, need to calculate the cost. This is all about adding consecutive numbers, so the formula of (n/2)*(1+n), where n represents the total number of steps for each number to the horizontal position comes into play.
Helping Sigal (my eldest) study for the SHSATs (NYC specialized high school entrance test) actually gave me the formula I needed to solve this one with a simple row by row, math approach.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Triangle numbers for the tool golf win
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Who knew there was so much controversy about crab movement!
- Stripped the data down into unique rows
- For each crab - generate all the target position candidates (yes - brute force)
- Then work out the cost - for the cost of the second one use the formula n* (n+1)/2 where n is the distance (that's the formula for this series)
... only realised afterwards that you can figure out the correct target spot using the median
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hmmm, I see a lot of solutions with "generate rows". Didn't even occur to me to try that. I only considered aligning to a position that at least one crab started at (634 distinct positions to start). Used those 634 positions as the control parameters into a batch macro. Part 1 was easy - distance/fuel = number of moves. Part 2 wasn't horrendous - as another stated, just (moves/2)*(1+moves).
