Discussion thread for day 11 of the Advent of Code : https://adventofcode.com/2020/day/11
Not the fastest or cleanest for part 2...
Part 2 (slow and messy ):
I've not solved it yet, but if anyone wants more background reading this is a modified version of Conway's Game of Life which I did play once before in Alteryx 🙂
https://www.youtube.com/watch?v=hcrVS5YOrm4&feature=emb_title
I'm almost embarrassed by those ugly generate rows. Almost.
Same iterative solves both, just update the rows that enter it.
At last a spatial problem!
Base workflow
Iterative Macro
Part 2 is going to need a refactor!
Mine was way to messy and hacked together for me to post... Wasn't that hard in theory, in practice it drove me crazy debugging it.
Quite happy with mine, my final solution makes up for the nightmare mis-read of part 1! Didn't resort to reddit or here today 🙂I had to leave this for a while to go and work after part 1 - wasted an hour by misinterpreting the part one as look 8 seats in each direction, not 8 seats, 1 in each direction.... DOH!
Iterative macro for part 1, then an iterative to prepare for part 2 by looking for the next seat in each direction for each seat as this doesn't change.
Then a modification of my part 1 macro to solve part 2. <1 min so not too horrible either.
Full
macro1
macro2 to prep part 2
macro 3 to solve part 2
Edit - also had fun seeing how the seats filled up:-
https://public.tableau.com/profile/petergb#!/vizhome/Day11_16077110205010/AoCDay11
Tidied up and did a better approach for iterative macro (doing so pre work) - got run time to a nicer 11s
Inner macro much simpler (and for both part 1 and 2):
Day11!
I'm getting used to Making Iterative Macros.
Part1 Macro:
Part2 Macro: to modify Lookup table with added rules. I used the Position Tag to modify it.
AS anonymous user #1105310
@jdunkerley79 a big win for AMP today. I took yours and got ~26s without it and ~12s with it. I think the big difference was being able to run the iterative macros in parallel. I've just tried with/without on mine and got similar numbers.
Today was a huge loss for AMP on mine. With AMP on, it runs faster, but comes up with the wrong answer! I got it down to 9.5 seconds without AMP.
https://github.com/NedHarding/Advent2020
I couldn't resist seeing how it played out - today's was fun!
Gif skips a few frames to be under the community size limit but you get the idea. Twbx is available for download here if you fancy a look.
Pretty low res and some frames skipped for the file size/upload but I couldn't resist seeing how it played out.Full version here Fun challenge today!
@NedHarding that is interesting, I see it on my machine too for your macro. 2119 for part 2 without AMP, 2117 with it turned on? It deviates from the second iteration onwatds.
Definitely needed a couple hints to get going on this one. It finally clicked when read people were using coordinate based approaches. And as I write this I am realizing I probably could have made use of spatial tools for distance calculations. Oh well... nothing wrong with brushing up on grade school math.
Macro
@Greg_Murray This one was interesting - you can cheat and use 1 dimensional distance. I just #'ed the cells 0 to 9024 and then used abs(a-b) for distance. The absolute distance doesn't matter, only the sort order.
Here's my solution for the first part. Like @Balders there are a lot of tools in the macro to force it to exit when it meets the condition of no seats changing between the iterations.
Macro:
It's late and it's Friday so I'll try and workout part 2 over the weekend.
Tried to edit my post yesterday but it disappeared..
Here's my iterative solution.
iterative to solve 1
iterative to prepare for part 2
iterative to solve part 2
It was really interesting to see the seating iterations develop too!
Watching the seats fill up is very satisfying!
So while my original idea of converting to spatial and using find nearest, like many of us did last year, showed promise but was WAY too slow.
Solution to part 1 is probably very convoluted, but it works, and it only takes about 30 seconds for the iterative macro. Not stellar time, not winning at tool golf, but at least it functions.
Part 1 workflow, simple enough
Macro. Ugh. But it works
A week between parts a & b for me as my son came home and busy with work before off for 2 weeks (but not from Alteryx 😃). Could have used the second macro for both with minor changes to workflow.