Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2022 Day 20 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team
Discussion thread for day 20 of the Advent of Code - https://adventofcode.com/2022/day/20
6 REPLIES 6
clmc9601
13 - Pulsar
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.

WorkflowWorkflowIterative macroIterative macro

 

DataNath
17 - Castor
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:

DataNath_0-1671575511841.png


Mixer:

DataNath_1-1671575538308.png
mmontgomery
11 - Bolide
11 - Bolide

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

mmontgomery_0-1671587651100.pngmmontgomery_2-1671587920574.png

 

 

patrick_digan
17 - Castor
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.
patrick_digan_0-1672837177128.png



patrick_digan_1-1672837240895.png

 

PangHC
12 - Quasar

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.

 

SeanAdams
17 - Castor
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



SeanAdams_0-1674941673492.png

 


SeanAdams_1-1674941754235.png

 



Labels