General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2022 Day 2 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

Discussion thread for day 2 of the Advent of Code - https://adventofcode.com/2022/day/2

45 REPLIES 45
Jean-Balteryx
16 - Nebula
16 - Nebula

Day 2 done ! 

 

If you need to work on your conditional statements game, here is the training !

I went for the nested IF statements ! Because where would be the fun otherwise ?

 

 

 

Spoiler
Capture d’écran 2022-12-02 à 09.15.51.png

Mathematical formula for part 1 :

 

 

Spoiler
Mod(CharToInt([Player]) - CharToInt([Opponent]) - 19, 3) * 3 + CharToInt([Player]) - 87

 

Mathematical formula for part 2 :

 

Spoiler
(CharToInt([Player]) - 88) * 3 + Mod(ABS(-CharToInt([Player])-CharToInt([Opponent]) + 151), 3) + 1
DataNath
17 - Castor

Day 2 done! This one took way longer than I care to admit... Which is what happens when you don't read the question properly and miss the part about draws, so assign your move based upon your opponent!

 

Spoiler
DataNath_0-1669973469167.png
AkimasaKajitani
17 - Castor
17 - Castor

I organized the pattern and I found that it is simple. So I remade the workflow as using formula tool.

 

Spoiler
AkimasaKajitani_0-1669973547199.png

 

Formula

Spoiler
Formula for Part1
ToNumber(
Switch(Right([Input],1),"0",
"X","1",
"Y","2",
"Z","3"
))
+
ToNumber(
IF [Input] IN ("C X","A Y","B Z") THEN "6"
ELSEIF [Input] IN ("A X","B Y","C Z") THEN "3"
ELSE "0"
ENDIF
)​


Formula for Part 2

ToNumber(
Switch(Right([Input],1),"0",
"X","0",
"Y","3",
"Z","6"
))
+
ToNumber(
IF [Input] IN ("A X","C Y","B Z") THEN "3"
ELSEIF [Input] IN ("C X","B Y","A Z") THEN "2"
ELSE "1"
ENDIF
)​

 

 

 

LiuZhang
9 - Comet
Spoiler
Day 2.png

A bit copy & paste on the formula, otherwise so far so good.

OllieClarke
15 - Aurora
15 - Aurora

Nothing clever about today's solution

Spoiler
OllieClarke_0-1669977555730.png

just write every option...

OllieClarke_1-1669977586494.png

 

DavidP
17 - Castor
17 - Castor

If statements not too untidy. @grossal does this count as 2 tools for tool golf?

 

 

Spoiler
DavidP_5-1669984354948.png

 

DavidP_0-1669987289549.png

 

 

Kenda
16 - Nebula
16 - Nebula
Spoiler
I just used text inputs for the different score combinations since there was a small, set number

Kenda_0-1669984803600.png

 

TheOC
15 - Aurora
15 - Aurora
Spoiler
I love switch statements, but working out X, Y, Z was a massive headache, especially in the second task!

TheOC_0-1669991288109.png

 

a bit of a tricky one!

Bulien
mmontgomery
10 - Fireball

Did the giant If Else If

Spoiler
mmontgomery_0-1669994246473.pngmmontgomery_1-1669994280683.png

 

estherb47
15 - Aurora
15 - Aurora

When I solved way past when I should have been sleeping, I created lookup tables for the different values and scores. 

Here is my tool golf solution. 3 tools: 

estherb47_0-1669994831064.png

 

Labels