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.
Iterative macros, generate rows, and hope for patterns! 1.15 minutes
Day one done, and dare I say easy?
Well, day 2, not so much......
Day 2: 1202 Program Alarm
And thus begins the twisting turning Intcode challenges. When @jdunkerley79 mentions that you should work on optimizing this one, you do (and as it turns out, we're revisiting this Intcode over several more days)
In a nutshell, we're processing numbers, 4 at a time. The first tells us the mathematical operator to use with the second and third, and the fourth tells us where to output the number. We've got to consider the entire list with every process, so it's looking to me like another iterative macro.
Pass 1. This works, but takes a long time. Need to optimize. Turns out that joins are faster than Appending in this process.
Part 1 done.
Part 2, we're seeking a specific answer, so need to send through a whole lot of number pairs to see which ones produce the result.
Original thought is to wrap the iterative macro from part 1 into a batch macro that feeds in the different pairs. Then wait. And wait. And wait some more. This is taking over 20 minutes, not an effective solution.
My initial iterative macro works pretty well, about 2 minutes. But, I'm running that with 10000 batches! There is no way this will complete in any sensible amount of time.
Back to the drawing board. Thought 1. Alteryx works well with large chunks of data, so let me alter my original macro to allow me to pass all variations of the number pairs through in one step (that is, no batch macro to feed in the pairs). with a little tweaking to the joins, this worked well.
Thought 2. Maybe there's a pattern to feeding in the different number pairs, so let me run a few through.
Increasing the second number increases the result by 1. Increasing the first increases by 320,000 (with my numbers). Use this to make a smaller list when generating the numbers.
Bingo!!! What approach worked for you?
Cheers,
Esther
@EstherB47 There may have been some luck involved, but my final approach for day 2 has seemed to work for all the intcode problems. I initially had a batch macro to iterative macro, but it was wayyyyyy toooooo sloooooooow. I eventually settled on doing string manipulation. I took the initial string (1,0,0,3...) and padded each number with 0's so that I can know where everything is located (000000001,000000000,000000000,000000003...). Then when I need to grab the first number, I can grab the first 9 numbers including my extra 0s (000000001) and remove the 0s. The second number would be characters 11-20 (000000000), etc. It's reduced the reliance on slow joins/appends. You can see my BaseA Day2 solution on github if you download my workflow and macro.
I did also use @jdunkerley79 's formula addins for a non-BaseA solution which is faster and my preferred approach for problems like this.
This was my first incode experience, so I went around the world trying to solve this one! I went with the batch-macro-that-runs-an-iterative-macro solution, which was unbearably slow.
Since it wasn't realistic to brute-force my way through a bunch of different noun/verb combos, I used some Interactive Chart tools to understand the relationship between noun/verb and the input. Since the relationships between noun/verb and input were linear, my first thought was to use a linear regression tool to get the coefficients for noun and verb (and then use Generate Rows and Score to generate predictions at various noun/verb values until I got to the right one).
However, I wasn't sure if predictive tools were in-bounds for Base A (they are!). Since the slope of the line was overwhelmingly driven by the noun, I did a very rough extrapolation of the known points to estimate the noun, and then ran my batch macro for a very targeted set of nouns.
My Advent of Code solutions are on github here: https://github.com/kelly-gilbert/advent-of-code/tree/master/2019-alteryx