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 2023 Day 12 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

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

14 REPLIES 14
gawa
16 - Nebula
16 - Nebula

Finally finished D12P2. As 2 days has already passed, I upload my WF this time.

 

Spoiler
My WF looks very simple, but needed uncountable attempts to make this.... 
image.png
DaisukeTsuchiya
14 - Magnetar

@Pang_Hee_Choy - Thank you so much for sharing super straightforward your solution.

I was stuck for so long time then I can get idea from your spoiler although I didn't download your WF. 
Finally I can finished after repeating debugging so many times. WF runs in 15 sec.
I can sleep tonight.

Spoiler
スクリーンショット 2023-12-14 214819.pngスクリーンショット 2023-12-14 214844.png

 

AkimasaKajitani
17 - Castor
17 - Castor

I struggled with Day12P2 but I finally got the second star!!!

 

I did not notice that the RegEx Match expression in a macro gave up to run, so it took me for long time.

 

AoC_2023_12_10.png

 

Spoiler
AoC_2023_12_3.png

Part 1 macro : simple macro


AoC_2023_12_4.png

Part 2 macro:

AoC_2023_12_11.png


In part 2 macro, I made it according to following term.

1. I convert rom ? to . and #
2. Create a definitive pattern on my own & delete the left-most number if it is already definitive.
3. Re-create Num.
4. Discard those that don't fit in the pattern check
5. Reduce the number of records by grouping and summing counts

This workflow takes 1 minutes to finish. 

 

SeanAdams
17 - Castor
17 - Castor

This is one of those days where it started out with brute force, and then Part 2 showed me the error of my ways.

It’s now running part 2 in ~17 sec – very happy with this solution!

 

 

Spoiler

Solution:

A few things that will help you as you think through this: 

  • Alteryx works with spaces much easier than . characters
  • A double . does the same job as a single – but it’s much easier to work with singles (because you can do a simple text match vs. target)
  • Leading & trailing . characters don’t add value but they do add complexity

 

So here’s the recipe:

 

SeanAdams_0-1702994112819.png

 

Parse the data

  • change . to spaces;
  • remove duplicate & leading / trailing spaces
  • Build a target string of what you’re looking for – e.g. 1,1,3 will be #.#.###

 

SeanAdams_1-1702994112828.png

 

Figure out valid combinations:

Repeat until you run out of strings with ? characters:

  1. For each incoming row, Create 2 rows – one that replaces the first ? with a space; and one that replaces it with #
  2. Trim leading & trailing spaces
  3. Trim duplicate spaces
  4. Throw away any strings which are shorter than the target
  5. Figure out where the next ? is – call this X
  6. Match the first X of my working string vs. the target – if it fails, discard
  7. Then check if any of our working strings are the same – if so, then keep a counter
    1. E.g. instead of having 2 rows with ###??? – instead keep 1 row with a counter of 2
  8. Loop

 

SeanAdams_2-1702994112838.png

 

 

This works fast for a few reasons:

  • Your number of rows that you are iterating with is very small because you compress them into a summary (step 7 above) and you are throwing stuff away as you go along
  • You are using simple string matches each time (all the complexity of leading and duplicate spaces is gone)

  

Tokimatsu
12 - Quasar

Just one summarize tool in one place made it dramatically faster. I can't tell you how long it took me to do that.

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

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

Labels