ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

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件の返信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 ?

 

 

 

スポイラ
Capture d’écran 2022-12-02 à 09.15.51.png

Mathematical formula for part 1 :

 

 

スポイラ
Mod(CharToInt([Player]) - CharToInt([Opponent]) - 19, 3) * 3 + CharToInt([Player]) - 87

 

Mathematical formula for part 2 :

 

スポイラ
(CharToInt([Player]) - 88) * 3 + Mod(ABS(-CharToInt([Player])-CharToInt([Opponent]) + 151), 3) + 1
DataNath
17 - Castor
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!

 

スポイラ
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.

 

スポイラ
AkimasaKajitani_0-1669973547199.png

 

Formula

スポイラ
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
)​

 

 

 

leozhang2work
ファイアボール
スポイラ
Day 2.png

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

OllieClarke
16 - Nebula
16 - Nebula

Nothing clever about today's solution

スポイラ
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?

 

 

スポイラ
DavidP_5-1669984354948.png

 

DavidP_0-1669987289549.png

 

 

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

Kenda_0-1669984803600.png

 

TheOC
16 - Nebula
16 - Nebula
スポイラ
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!
Cheers,
TheOC
Connect with me:
LinkedIn Bulien
mmontgomery
11 - Bolide
11 - Bolide

Did the giant If Else If

スポイラ
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

 

ラベル
トップのソリューション投稿者