General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2023 Day 1 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

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

80 REPLIES 80
cgoodman3
14 - Magnetar
14 - Magnetar
Spoiler

Fairly fast first part to the question, I know there are faster methods such as cleanse and left() right() string functions... but it's 5am for me. So went with the reverse string option to find the last digit. Solved at 5:04am which is my fastest star for doing AoC so I was pleased with that.

My test for part two worked perfectly.. however in the example where it showed sixteen, this evaluated to six (ignoring the teen). So when I ran this on my data and got the wrong result, I thought aha, while sixteen works as it contains six, what happens when you see things like twelve so I would need to extend my lookup table. So after writing out loads of number then got to twenty and then released how am I going to deal with twenty vs twentyone - as I don't want twenty one to become 201... I decided to inspect my input file.
Great I thought no number > 9. However I didn't immediately spot things like eightwo. So after a bit of two and through started to write these out manually with oneight, twone, etc. But unlike @joshbennett who correctly did this programmatically, I made the mistake of missing some pairs. So it took about 40 mins to complete part 2!

day1_2023.png

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
Samantha_Jayne
Alteryx
Alteryx

Yeah! Figured it out in the end, those elves are such tricksters first thing on a Friday morning! 🤣

 

Spoiler
Day 1.png

I tried to keep it flexible initially knowing what AoC is like, I was so excited that I only had to add a find and replace tool to then lose too many minutes wondering why my answer wasn't right. It wasn't until I saw rows three and four in my dataset did I realise why... 

Oh what fun!! Merry Advent of Code everyone
Samantha Clifton
Alteryx
#alteryxrocks
Carlithian
11 - Bolide
11 - Bolide

oooo, if someone came to me with data like this I would not be a happy chappy 😂 getting past the grumpyness and the urge to make everything a macro, sorted it pretty simply 

 

Spoiler
 

Spoiler Snippet.png

 

TheOC
15 - Aurora
15 - Aurora

I feel like I got lucky; the lookup gave me the right answer without any 'oneight' issues. I'll take the blessing on day 1, it will come back and bite me by day 5 😁

Spoiler
 

Alteryx wont let me upload images for some reason, but I abused regex to get me the first ( (\d) ) and last ( (\d)(?!.*\d) ) digit of the text.

Step 2 was a simple lookup for me, as mentioned I feel I got lucky on that one with no nasty lookups.

 


Bulien
Carlithian
11 - Bolide
11 - Bolide

For such a small dataset, why would you not hard code it? Or simply challenging yourself

mark-spain
6 - Meteoroid

Part 2 took me a while, I decided to brute force it all in a single Formula tool.

 
 
Spoiler
FormulaTool.png

 

AsmiDesai
9 - Comet

 

Spoiler
Spoiler
1st --> 😁
2nd --> 😫
Capture.PNG

 

 

Yoshiro_Fujimori
15 - Aurora

Part 2 took a while to get the point (just like the last year 😉)

Spoiler
Workflow
AoC01_WF.png

OllieClarke
15 - Aurora
15 - Aurora

Part 2 got me far too angry for day 1

Spoiler
image.png

My RegEx Parsing:
IF REGEX_CountMatches([Input],'\d')>1 THEN
tonumber(REGEX_Replace([Input],'\D*(\d).*(\d)\D*','$1$2'))
ELSEIF REGEX_CountMatches([Input],'\d')=1 THEN
tonumber(REGEX_Replace([Input],'\D*(\d)\D*','$1$1'))
ELSE 0
ENDIF​

My overlapping number replacement:

REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(lowercase([Input]),'one','o1e'),'two','t2'),'three','t3e'),'four','4'),'five','5e'),'six','6'),'seven','7n'),'eight','e8'),'nine','9')
mceleavey
17 - Castor
17 - Castor

I don't care what you say about me, I hardcoded, ok??

 

Spoiler
Screenshot 2023-12-01 124430.png

I created a text library of the words and corresponding digit, as well as the double digits for the overlaps (cheeky elves!), I then simply used Find and Replace to create numbers from the words.

I then used the formula:

 

tonumber(left(REGEX_Replace([Config], "[^\d]", ""),1)+right(REGEX_Replace([Config], "[^\d]", ""),1))

 

This simply removed everything but the digits, and takes the first and last characters.



Nice start. 

 

M.

 

 



Bulien

Labels