alteryx Community

# General Discussions

Discuss any topics that are not product-specific here.

## Advent of Code 2022 Day 20 (BaseA Style)

Alteryx Community Team
6 REPLIES 6
13 - Pulsar

Grateful for straightforward iterations this time

If you feel very stuck on part 1 and your macro works on the example but not on the real data, this hint might help you:

Spoiler
When the current item's movement is > number of items, you should NOT count the current item in the second+ loop around. More details in the workflow spoiler.

Solution:

Spoiler
It helps to calculate the remainder for any movements greater than the list of items. When calculating net movement, be sure to take number of items - 1 so that you don't count the current item in your list again.

WorkflowIterative macro

17 - Castor

Day 20 done! Not quite as straightforward as I first thought when reading through - the wrapping logic was fun to work out though!

Spoiler
Workflow:

Mixer:

8 - Asteroid

Got stuck for way too long figuring out the mod logic but once I did it was pretty quick.

Spoiler
1. Needed to setup data with base and iteration input
2. Did the length of string as my iteration write output, sample was 7, so it would write out 7th example/5000/50000th etc
3. Iteration = record ID
4. Set order as base 0
5. The mod function was key: if [Current_Order] >= [Length] then Mod(Current_Order, ([Length]-1))
elseif Current_Order < 0 then Mod(Current_Order, ([Length]-1))+[Length]-1 else [Current_Order] endif

17 - Castor

This was by far my least favorite puzzle. It just took way too much time to wrap my head around.

Spoiler
I took the path of least resistance for part 2 and just copied and pasted.

11 - Bolide

it least favorite for me too.

Spoiler
part1:
Exact one round, i waste 2hours and can't figure why, until I re-read the question. (at least I can use for part2)

MOD part, not understand why required to -1.  (i.e. mod([Movement],[Length]-1))
explanation I saw, it due to remove itself from the list.
does it mean 0 = 5000 here, then have to remove?

Plan to use math to calculate the SortOrder, but I can't figure out the answer.
no choice to move to method that re-build the recordID.

part2: simple if solved part 1.

17 - Castor

This one took a while for 2 reasons:

a) spent a lot of time chasing the wrong path - forgetting that it's a truly circular loop

b) silly mistake when starting part 2 which took me a while to find.

Spoiler
So the way that this works is pretty simple:

- Figure out the new position by using a mod operator.
- take the current position; add the delta; and then mod this with 1 less than the record count
- then insert this in the list just ahead of this calculated position (e.g. position 3.1)
- Renumber the positions
- Next turn

Because the move is being done with a mod operator - part 2 works exactly the same as part 1

Labels