General Discussions

Discuss a wide range of topics! Questions about the Alteryx Platform should be directed to the appropriate Product discussion forum.

Advent of Code 2021 Day 16 (BaseA Style)

16 - Nebula
16 - Nebula

Discussion thread for day 16 of the Advent of Code -



8 - Asteroid
16 - 1 unsolved.png16 - 2 unsolved.png

Stuck on part 1, don't know why it doesn't work.

For most of the sample code given, it works. Though for code with more than 2 sub_packet split, I will need to manually add more macro. (As my data has only one split, so it should work.)


General idea is to handle string as instructed, use substring to progress in series.

11 - Bolide

Just took 2 hours to read the prompt. Painful iterative. Wanted to keep track of the hierarchy but those packets that contain X number of packets are a pain...

inner iterative. The workflow works with all the example inputs. With the actual input, it fails. Somewhere. But gets close enough -- after some fruitless debugging I thought there were just one or two packets missing, and luckily it was true as the output was just 7 points shorter (some faith and some trial and error proved that 😅).


The hierarchy is all messed up (stored in recordID), so no way I can tackle part 2 as it stands... number_dec 8 RecordID version 0 type 4 children 




16 - Nebula
16 - Nebula

phew, finally got part 2 to work.

After reading (and rereading) the instructions, I finally understood what was going on. 


Part 1 macro wasn't too complex. Regex was a big help on the getting the literal values. TIL that you need to put a + in front of your string if it's exactly 32 characters:


Part 2 macro was much worse and took some refactoring after it worked on the samples but not my data. Basically I process as many subpackets as possible and then try again.





17 - Castor
17 - Castor

WOW - that took a day to figure out an approach and to execute.     To be fair to the problem, I'm not a speed-developer like @NicoleJohnson .    This is another one of these problems that would be much easier to solve in a single pass using recursion, but Alteryx doesn't have this yet.  


Fun part of this was that I got to use something I learned a while ago from @patrick_digan - the Dynamic Replace, and it's ability to create code that can be created & executed dynamically.



OK - here's the recipe I followed:
Step 1: Hex to Bin - did this in a separate macro
Step 2: Lex out the operators into a list - i.e. convert the binary stream into a list of operators and literal values
Step 3: iteratively process this list of operators, working from the bottom of the tree upwards (sorta like working from the inner-most brackets outwards)
- The way I did this was to start at the bottom of the tree - for example look for things like Greater Than followed by 2 literals)
- Work out the result of this leaf
- Replace all the rows that were part of this calculation into just 1 row which is a literal
- Repeat
Step 3a: 
- to do the "work out the result" piece - dynamically created a quick formula - and then used Dynamic Replace to execute it.

For example:
Operator Sum
    Operator Literal 3
    Operator GreaterThan
         Operator Literal 15
         Operator Literal 3
    Operator Literal 2

The italic bits now resolve down to a single line which is a literal
Operator Sum
    Operator Literal 3
    Operator Literal 1
    Operator Literal 2

Then you do Sum and this collapses to 
Operator Literal 6

which is the answer.

Main flow:



Then the lexer 

Then the part that iteratively solves the tree



And finally the piece that executes the calculations






10 - Fireball

Spent 3 week (everyday 3 hours though)... to complete this. 


Part 1 is completed accidently...i just try and error.

but to complete part two, take of 90% of time to built the nice Tree for numbering, operator and Len. look good but quite useless 😅

luckily the length set is exactly same without any dispose digit, if not it will take 2 more week.

with this nice tree, I can do part 2 easily.

thank @SeanAdams for the workflow. so that i can realise i very close to the correct answer.
thank @patrick_digan for mention the sign issue in BintoInt conversion, just a steps to the correct answer.
i was thought a ABS function will solve the issue.





17 - Castor
17 - Castor

I'm with you on this @Pang_Hee_Choy - I'm still crunching my way through the last 3 AOC challenges.