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

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2023 Day 14 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

Discussion thread for day 14 of the Advent of Code - https://adventofcode.com/2023/day/14

15 REPLIES 15
alisonpitt
11 - Bolide

I like any chance I get to use transformations and string parsing. Part 2 was a lot of trial and error, but I got there in the end (thank goodness for example data!).

Spoiler
The gist of my solution was that I rotated the whole matrix 90 degrees ccw and dealt with the columns as groups of strings, breaking them apart and using padleft and padright to rebuild in the right order. For part 2 I did this in conjuction with rotating the whole board cw before doing all the string manipulation, so basically the tilts were all the same motion and I rotated the frame of reference.

I assumed a loop since 1,000,000,000 was too big a number to feasibly do brute force - took me a while to find it, though; you have to make sure to run through enough cycles to trigger a loop.
14-1-ap.png14-2-ap.png14-2-macro-ap.png

Curious to see whether I'll manage more of these before Christmas - the holiday things are get busy around here!

mmontgomery
11 - Bolide
11 - Bolide

P1 wasn't pretty and P2, well, ugly is an understatement to get the base loop to work. More in spoiler

Spoiler
For P1, I wrote the logic for the north route without too much of a fuss. I took very inefficient routes to scale it when I should have built all four separately for P2.

My goal was to move all the items at once in P2, which required some over-engineered multi-rows to check to see which value the 'O' was between '#' as well as the direction needed to determine max/min locations.

Finding the final loop was rather straightforward: I did a loop of 300 cases and then did a self-join between the iterations on row, column, and value to find when there were 100% matches. Once I saw the pattern, I did some math to find the magic iteration number and ran it pretty quickD14P1_2.pngD14P2Macro.png

PangHC
12 - Quasar

update workflow with 40~ seconds.

 

Spoiler
instead of move rock, step by step, and revisit same rows even it nothing to moved.

I change to use regex formula after concatenating by x/y
REGEX_Replace([data], "(\.+)(O+)", "$2$1")​

and filter it if the rows nothing to move.
hence, the iteration and data size are reduced, it speeds up 97%.

updated macro: 
Screenshot 2023-12-18 111418.png

 

 

estherb47
15 - Aurora
15 - Aurora

Satisfying to finally get the solution, and I think I lucked out with a data set that lent itself to clarity as to what was repeated in the pattern.

 

Anyone else find it easier to solve for part 2 using the real data instead of the test data?


 

To figure out the repeats, I basically looked where consecutive rows that appeared more than once started. The first one marked the starting point. Looked where that repeated to find how many records in a cycle, and then extrapolated that pattern to 1000000 to find the answer.

Carolyn
12 - Quasar
12 - Quasar

@phottovy - I'm sort of irritated with you for how nice and compactly you did the N/E/S/W bananas. I overcomplicated mine by a factor of 100 :D 

Tokimatsu
12 - Quasar

Finaly done.

Spoiler

スクリーンショット 2024-01-05 155622.png

 

Labels
Top Solution Authors