Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2022 Day 22 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team
Discussion thread for day 22 of the Advent of Code - https://adventofcode.com/2022/day/22
9 REPLIES 9
mmontgomery
10 - Fireball

Most of P1 was spent setting up the problem (more in the spoiler). I'll need to get my head wrapped around P2

Spoiler
1. Setup coordinate so each point has 4 adjacent points defined to account for empty space/falling off map
2. Generate direction and I used 360 degree calcs to determine overall direction 

3. I macro for path

mmontgomery_1-1671732762894.png

 

mmontgomery_0-1671732743738.png

 

 

DataNath
17 - Castor

Part 1 done! Part 2 looks like it'll take me a good while to wrap my head around so will come back to update this if I ever get round to finishing it!

 

Spoiler
Workflow:

DataNath_0-1671748113091.png


Macro:

DataNath_1-1671748231880.png

Just for fun - my rough path. Obviously can't show wrapping too well:

DataNath_2-1671748387268.png

... Eric really loves his position-based problems! 

ShankerV
17 - Castor
patrick_digan
17 - Castor
17 - Castor

Ha so I spent forever coding up part2 but thankfully it worked.

Spoiler
Definitely a slow and steady approach moving a single cell each iteration.
patrick_digan_0-1672837566357.png


patrick_digan_1-1672837594893.png

 

 

AkimasaKajitani
17 - Castor
17 - Castor

Finally done.

 

Spoiler
I solved part 1 straight forward.
But it took long time to solve part 2 because debugging is too difficult more than part 1.

Firstly I tried to solve part 2 by modifying the part 1 macro but failed because my part 1 macro is dirty and inefficient. So I remake the macro for part 2 which is simple and clean. After that, I compared the results of 2 version macro and finished debugging.

And I also created the following to help debug(I printed this image and acctually assembled it).
AoC_2022_22_6.png
And I made the following table from above image.

DirectionCurrent AreaTarget AreaDirection in new areaaxis directionx in new areay in new area
RADLreverse100150-y+1
RCAU y+5050
RDALreverse150150-y+1
RFDU y-100150
LBERreverse1150-y+1
LCED y+50101
LEBRreverse51150-y+1
LFBD y-1001
UAFU x-100200
UBFRreverse1150-y+1
UECR 51x+50
DACL 100x-50
DDFL 50y+100
DFAD x200


AkimasaKajitani_0-1673162400530.png

Part 1 macro: dirty, inefficient and slow macro

AkimasaKajitani_1-1673162439662.png

Part 2 macro : efficiently, simple and fast. This is only for my input. If it is the same as my cubic development, it will work well.
AkimasaKajitani_2-1673162477604.png

 


 

 https://github.com/AkimasaKajitani/AdventOfCode/tree/main/2022

clmc9601
13 - Pulsar
13 - Pulsar

I had to fold the cube on paper before I understood how to program part 2.

Workflows available here: https://github.com/clmc9601/Advent-of-Code-solutions/tree/main/2022%20Alteryx

 

Spoiler
My approach was to create all of the consecutive coordinates based on the instructions, then cut the movement off once it reached a wall. I wrapped the movement around based on min and max row and column coordinates. For Part 2, I basically created a coordinate conversion table to translate between absolute map coordinates and relative coordinates for rotating around the cube. I made one mistake in Part 2 that took several weeks to solve: I originally precalculated the facing direction. This became problematic when the directions "switch" around the cube. To correct it, I needed to calculate direction based on the previous iteration's direction.

Main workflowMain workflowIterative macroIterative macroWorkflow to create the conversion tableWorkflow to create the conversion tableInput code in sectionsInput code in sectionsInput code as on a flattened cube (referenced in the conversion table workflow)Input code as on a flattened cube (referenced in the conversion table workflow)

Pang_Hee_Choy
12 - Quasar

take few days. and finally get it.

Spoiler
part1: easy with min and max for x and y.

part2: view lot of post still can't figure out. the last mile, the formula mistake.

do the most stupid way. hardcode all the next step for all transition. point the corner for ease of imagine.
Pang_Hee_Choy_0-1674027020626.png

so from, 

1st round: A move to B,
become,
1st round: A move till transit point, adjust face
2nd round: transit point move to B.



it takes slightly more time but easier to check. 
SeanAdams
17 - Castor
17 - Castor

:-) so this took a while - but I figure better late than never.

 

Along the way - also built a few helper macros - one to show the shape of the grid; one to generate test grids; etc....

Testing was key on this - start with generating a 1x1 cube in the required shape, test that across all transitions; then move to rotation on a 1x1; then move to a 2x2; then add in rotations and movement within a face; then move to 4x4; then add in blocks. 

That way - didn't spend time backtracking - every single step was built on a previous solid step.

 

Spoiler
The approach here was to identify the particular structure of the cube - this is called a "Net" which is the fancy term for how you represent a box if you open it up flat.   Turns out that there are only 11 possible nets.
SeanAdams_0-1684221123047.png

 


The shape of the example data was not the same as the user problem - so I built some cubes in real-space; and used them to figure out the transitions across faces.
example shape:
SeanAdams_1-1684221238752.png

User problem shape:

SeanAdams_2-1684221278087.png

 

Transition Map
The transition maps had 2 parts.     One is a generic map which say "if I exit the top of one face, and that lands me on the left hand size of the next face - what does that do to row; column and direction".    This is common across any shape.    This was worked out with paper squares in real-space - I'm sure there's a computational method to figure it out...

SeanAdams_3-1684221421732.png

 

The second half is specific to a given layout - and it says "if I leave the top of Face 1 - where do I end up".    I am pretty sure that this could be worked out computationally given that there are only 11 possible nets, but didn't have an easy solution in mind, so I mapped this manually:
SeanAdams_4-1684221539826.png

 



The solver:
The prep macro breaks this out into cells and board-size; and a discrete list of moves
SeanAdams_5-1684221620357.png

 



Then used an iterative macro to go through each move one by one to solve it





SeanAdams_6-1684221813130.png

Iterative solver:

SeanAdams_7-1684221897041.png

 



This did feel like a bit of a cheat because I created the transition maps to fit my particular user input, but what makes me feel OK is that it did run 56k iterations to get to the solution, and that was all computational (so it wasn't a hand-solve.


 

 

 

MeganDibble
Alteryx Community Team
Alteryx Community Team

@SeanAdams Christmas in May! 😀 Love the detailed answer

Labels