General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2023 Day 7 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

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

39 REPLIES 39
Kenda
16 - Nebula
16 - Nebula

@patrick_digan wrote:

Probably not the straightest path there but it worked.


 

If you use Ctrl Shift + it would be a straighter path 😉

rachel_k
Alteryx
Alteryx
Spoiler
day7.jpg

It's not pretty, but it worked.  I edited part 2 right on top of part 1, so this won't work for part 1.  

FrederikE
13 - Pulsar
Spoiler
Screenshot 2023-12-07 162859.png


mmontgomery
11 - Bolide

Tried to get too cute on p2 and simplified it.

Spoiler
Day7.png
StevenP
8 - Asteroid

My Solution:

 

Spoiler
image.png
I applied a ranking to the hand types and each card value and did nested sorts within each to determine the true order.

In order to account for Jokers I looked at the relevant hands and determined the best card to "add" the joker into.
For example: the hand KTJJT has three different cards K/J/T with T being the most frequent card with 2 instances. Taking the max value of 2 and adding the count of jokers (2) to it results in a count of 4 making it a four of a kind. To account for the fact that a native four of a kind is always better than one that uses jokers I did not convert the original hand to be KTTTT but left it as is. The Type_Code however was updated from Two Pair (2,2,1) to Four of a Kind (4,1).

 

 

Carolyn
8 - Asteroid

Solved! That was a fun one. I ended up with a very bizarre detour with a couple of Multi-Rows to handle the Jokers and getting them sorted properly

 

Spoiler
2023-12-07_10-37-22.png
phottovy
13 - Pulsar
13 - Pulsar

Fortunately I was able to use most of my solution for part 1 for part 2. Detour tools for the win!

 

Spoiler
07.png
mceleavey
17 - Castor
17 - Castor

Another easy one today...

 

Spoiler
1.pngHands.png

It's not pretty, but I went down the route of splitting out the data into it's parts, then tokenizing to rows on the cards by individual characters, so I had a card per row. I then grouped by Hand and by card to get a count of each card per hand. I then filtered (many times) to determine if they had 5,4,3 or 2 of any kind in a hand (this process had to be repeated).
This got me to a point where I determined the hand rank (1 being 5 of a kind and so on).
I then brought in the card scores from a text input to join. From here it was a case of ranking them in Hand ranking order, then sorting by 1,2,3,4 and 5 in order by card score.
I then used two record IDs with an order shift in between as a quick way of scoring highest to lowest (could have done that earlier)

For part two I used a formula to determine the hand shift according to no. of Jacks:

if [No. Jacks]=0 THEN [Hand Rank]

ELSEIF [Hand Rank]=1 then 1

elseif [Hand Rank]=2 AND [No. Jacks]>0 then 1

elseif [Hand Rank]=3 AND [No. Jacks]>0 then 1

elseif [Hand Rank]=4 AND [No. Jacks]>0 THEN 2

elseif [Hand Rank]=5 AND [No. Jacks]=1 then 3
elseif [Hand Rank]=5 AND [No. Jacks]=2 then 2

elseif [Hand Rank]=6 AND [No. Jacks]=1 then 4
elseif [Hand Rank]=6 AND [No. Jacks]=2 then 4

elseif [Hand Rank]=7 AND [No. Jacks]=1 then 6

ELSE [Hand Rank] ENDIF

and the card score was adjusted in the text input.



So there you go, @phottovy , enjoy!



Bulien

Samantha_Jayne
Alteryx
Alteryx
Spoiler
Day 7.png
ok I am busy closing deals and rushed this one. #sorrynotsorry 
Don't try to understand it, ill clean it up another day and upload! 
Good news is though I got the right answer in all that spaghetti 🤣
Samantha Clifton
Alteryx
#alteryxrocks
DavidP
17 - Castor
17 - Castor

I didn't over think and over engineer my solution to today's problem and anyone who says any different is a big fat liar!!!!!!!!!!!!!!!!!!!!

 

Spoiler
aoc d7.png
Labels