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

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team
Discussion thread for day 7 of the Advent of Code - https://adventofcode.com/2022/day/7
31 REPLIES 31
DataNath
17 - Castor

Finally got Day #7 done! This was honestly awful and took way longer than any human should spend on a workflow.

 

Spoiler
DataNath_0-1670430453341.pngDataNath_1-1670430464424.png
mmontgomery
10 - Fireball

Finally! Big assist to Kelsey whose logic got me across the finish line. 

 

Spoiler
mmontgomery_0-1670449731561.png

 

estherb47
15 - Aurora
15 - Aurora

My solution is not my most elegant. And I'm morally opposed to repeated folder names in the nesting.

Spoiler
estherb47_0-1670453814578.png

 

SeanAdams
17 - Castor
17 - Castor

what a mess - this took WAY longer than it should have - I was stuck on a bad RegEx path and had to abandon that.

 

Dirty solution below

 

Spoiler
SeanAdams_0-1670467362330.png


This creates a folder for every file - and then duplicates each file for every level of parent.
Much more painful than it needed to be

Part 2:
Just took the working data from part 1 and popped them into a different summary.   Once I'd done part 1 - part 2 was a breeze.

SeanAdams_1-1670467459273.png

 

Kenda
16 - Nebula
16 - Nebula
Spoiler
Kenda_0-1670470026020.png

 

Yoshiro_Fujimori
15 - Aurora

My solution.

I am not good at macros, but this time it worked.

 

Main

Spoiler
Yoshiro_Fujimori_0-1670474880628.png

Multi-Row Formula to get Path

Spoiler

IF [Field_1] = "$ cd /"
THEN ""

ELSEIF [Field_1] = "$ cd .."
THEN RegEx_Replace([Row-1:Path], "(.*/).*/", "$1")

ELSEIF StartsWith([Field_1], "$ cd ")
THEN [Row-1:Path] + Replace([Field_1], "$ cd ", "") + "/"

ELSE [Row-1:Path]
ENDIF

Macro to get total size of files under a Path

Spoiler
Yoshiro_Fujimori_1-1670475130923.png

 

peter_gb
9 - Comet

I didn't use a macro! Mostly because I was copy and pasting a set of tools to test my logic before building the macro, once I'd tested 4 levels it was one copy and paste and as much clicking as making the iterative macro to get to the answer. Already lost hours to it so stormed ahead with the "it ain't pretty but it works" approach, as with most of my AoC attempts. Stil. Got stars and that's what we're here for. Will return and do the macro properly soon...

Spoiler
peter_gb_0-1670509412489.png

 

clmc9601
13 - Pulsar
13 - Pulsar

I'm sure there's a more efficient Python solution than this #SnakingMyWayThroughChallenges

 

Spoiler
Day 7 Python.png

LiuZhang
9 - Comet
Spoiler
MacroMacroWorkflowWorkflowDay 7 - 2.png

Thanks @balders-ie's hint, FileGetDir() is a life changer. Part 2 confused me quite a bit, after reading the questions over and over again, just used common sense for it.

JoshuaB
Alteryx Product Evangelist
Alteryx Product Evangelist

Not only a brilliant use of ReverseString but also looping through it using the generate rows! Love it. 

Joshua Burkhow | Chief Evangelist @ Alteryx | Follow me on LinkedIn and Twitter
Labels