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.
Discuss a wide range of topics! Questions about the Alteryx Platform should be directed to the appropriate Product discussion forum.
General Discussions has some can't miss conversations going on right now! From conversations about automation to sharing your favorite Alteryx memes, there's something for everyone. Make it part of your community routine!
Iterative for the first part and then just duplicated the data for the second part so that way it's pretty fast still (4.4 seconds for parts 1 and 2). Similar to intcode last year, I just stuff the input into a single long string with everything spaced appropriately so that I can get objects based on position. I was using a lot of macro outputs to debug...
I DID IT!! I figured out how to do this one without macros!!!!! Now to be fair, I solved it the hard & painful iterative-macro-within-an-iterative-macro way last night when I was trying to get stars... but then I spent all night not sleeping thinking there had to be a better way, and lo and behold, IT WORKED.
First solution (runs both parts in 30+ minutes, + Iterative Macro Inception):
Relatively simple workflow, relatively un-simple macros... though the first time I've used the automatic text input tool for AoC, courtesy of @NedHarding - thank you for the instructions/macro for this magical input option, Ned!! Part 1 macro (which is also used in the Part 2 macro) - I'm not even sure at this point what it is doing, but has something to do with updating the value & the next instruction number for each iteration. And probably some extraneous inputs that are no longer needed... it was like 11:30pm by the time I finished, and I never want to see this thing again. Part 2 macro, which will run the selected jmp/noc replacements through the Part 1 macro. Took about a half hour to run on my server - was shaping up to take 5 or 6 times that long on my laptop. I made it an iterative macro because it was slow and I wanted it to stop running the first time it ran into a scenario where it completed, rather than running ALL scenarios, potentially unnecessarily. I sort of hate this solution... but it worked, so there's that.
Second solution (Runs both parts in ~26 seconds + NO MACROS):
By combining the instructions into a single standardized pattern and then using a goofy but quite functional Substring+RegEx_Replace Multi-Row Formula, this ended up being extremely efficient and so much simpler to understand (and modify in future challenges, probably) than the macro-inception route above! I think I could make this work for running Part 1 & 2 at the same time with some tweaks to the post Multi-Row tool logic, a la Ned's approach that I see is sans macro as well - the Multi-Row formula tool is exactly the same for both parts, with the exception of grouping by Batch ID in Part 2.
Definitely not winning tool golf here. And I love @NicoleJohnson 's method of putting the row skipping and accumulator into one tool. For my brain, worked better in 2 multirows. Plus I added another multirow tool to see if codes repeated because I hated that the unique tool sorted the data and then I had to sort again to get back into order.
23.1 seconds. No macros. Take that, Intcode nightmares!!! Part 1 only took .7 seconds, which amazed me.
Credit goes to @patrick_digan 's method of concatenating and replacing pieces of code from last year. Worked like a charm.