Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2023 Day 15 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

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

15 REPLIES 15
kelsey_kincaid
12 - Quasar

Today was a good confidence booster! I started by trying to avoid an iterative macro, but found the logic was more straightforward with a macro than without (at least to me). Now I want to go back and try a non-macro solution!

 

 

Spoiler

 

Part 1: 
The bulk of this logic was done in a simple multi-row formula tool with built-in Alteryx functions, which just felt so good. CharToInt() was so useful.



Part 2:
After rereading the instructions approximately 15 times, I finally felt like I understood the problem. It luckily sounded much more complicated than it ended up being in practice.

  • Re-apply the "HASHMAP" algorithm to just the lens label instead of the full string
  • Find the first line with a = operation and remove any records before that. My production data wasn't working in my iterative macro because the first 3 operations were removals, so this was my solve for that.
  • Find max iterations and use that to stop the macro
  • Use iterative macro to see if a label already existed in a box, and apply the operation. The workhorse of this macro is the join tool between the box map and the instruction set.

Workflow:

D15.png

 

Macro:

D15 Macro.png

 

 

AndrewDMerrill
13 - Pulsar

This was a fun one, once I figured out the instructions (which took me longer than I'd like to admit...). The method here is pretty much just brute force, so I won't share any further details as to algorithm. I think the workflow itself is a pretty cool use-case for creating conditional logic in Alteryx (i.e. update if row exists, add row if not)

 

Workflow:

 

Spoiler
Main Workflow:
_Main Workflow.png
Hash String (iterative macro):
_Hash String.png
Fill Boxes with Lenses (iterative macro):
_Fill Boxes.png

 

 

phottovy
13 - Pulsar
13 - Pulsar

I probably spent more time rereading the description than actually building my workflow.

 

Spoiler
15.png

P1:
15_P1.png

P2 (which also reuses the P1 macro:
15_P2.png
DaisukeTsuchiya
13 - Pulsar

P2 is hard to understand the problem.

Spoiler
I lost my way to find Box2 in P2 sample. @gawa gave me one sentence hint then I got it.
Thank you.

スクリーンショット 2023-12-15 174413.png
<Macro for P2>
スクリーンショット 2023-12-15 175709.png
gawa
15 - Aurora
15 - Aurora

It may take a bit long to understand what you are asked to solve in part2, but once you get it, logic would be simpler.

Spoiler

image.png
Pang_Hee_Choy
12 - Quasar

I read part 2 for 20+ times. to find out how to allocate the box.

and today also a non macro day. 

 

Spoiler
Part1: token > multiple tool

part2:
1. use part one method for label only (note: input more that 2 characters, waste lot of time to found this)
2. sort descending RecordID
3. take first "=" for value, and take last "=" before "-" for RecordID
4. sort RecordID back to ascending and add sequence_num (slot) by box.
5. calculate as request and sum

recordIDlabelactionvalueboxtyperemark
10aa=51takefirst, for value
7aa=41takelast, for recordID
5aa- 1stop 
3aa=31stop 
1aa=21stop 

Screenshot 2023-12-15 172902.pngScreenshot 2023-12-15 172830.png

 

 

cgoodman3
14 - Magnetar
14 - Magnetar
Spoiler
I'm surprised with all of the macro based approaches, especially when there are not many macros for part 1.

Part 2 the trick is to group the values by the boxes and then you just need to work out if the operation is to add a new lens, replace an existing lens or take a lens out. So you can build out a string with the lens in order and make use of regex_replace functions to either replace or delete. 

day15_2023.png

Spoiler
Multi-row for part 2:
IF !Contains([Row-1:lensBox],[label]) AND [Operation] = "=" THEN
[Row-1:lensBox]+"["+[label]+" "+tostring([FocalLength])+"]"
ELSEIF
Contains([Row-1:lensBox],[label]) AND [Operation] = "="
THEN
REGEX_Replace([Row-1:lensBox], [label]+'(\s\d)', [label]+" "+tostring([FocalLength]))
ELSEIF
[Operation] = "-" AND contains([Row-1:lensBox],[label])
THEN
REGEX_Replace([Row-1:lensBox], '(\[)'+[label]+'(\s\d\])',"")
ELSE
[Row-1:lensBox]
ENDIF

(Ignore the lack of indentation!)
Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
AkimasaKajitani
17 - Castor
17 - Castor

Part 1 is straightforward. But Part 2 question text was too difficult to understand. I continued to search the box number.

 

Spoiler
AoC_2023_15_07.png

AoC_2023_15_06.png

Raj
15 - Aurora

Had to spend a good amount of time reading the situation again and again. 
although the part 1 was not complicated as excepted 

 

Overall, a good challenge so far and got to know about the ASCII value

Formula use for part 1 - Mod(([Row-1:value] + CharToInt([data]))*17,256)


example if ASCII values 
a 97
b 98
c 99
d 100
e 101
f 102
= 61
- 45
1 49
5 53
t 116

Labels