Discussion thread for day 2 of the Advent of Code - https://adventofcode.com/2022/day/2
Such a fun way to get the brain going in the morning!
If Statement for the win! There are more clever ways to do this but this got the job done relatively fast for me:
Fairly simple once I'd actually read the second question.
Turns out that's quite important.
So, I created a mapping table as follows:
this allowed me to simply join the first and second columns. Then for the first answer I simply built an IF to calculate the points then sum them:
(if [Outcome]= "Win" then 6 elseif [Outcome]="Draw" then 3 else 0 endif)+ (if [2]="Y" then 2 elseif [2]="X" then 1 else 3 endif).
The second part was a couple of IFs to determine the required play given the Required Outcome, then the associated points.
Noice.
Reply number 1: This is the raw solution - refactor to follow.
this is part of the practice of Red-Green-Refactor (TDD)
So here's the first post - my messy solution (Red & Green) - refactor to follow.
Not super happy with my solve on this one - it feels clunky. I might give this some thought and come back to it when I'm not trying to move as fast!
@DavidP it doesn't count. As discussed in the WhatsApp group earlier: For tool golf, both answers have to be provided in a single cell output. Therefore you'd need two Summarize tools :-)
Lots of find replacing going on here, but gets the job done haha. I opted to build out the selection / results and points mapping in tables rather then messing with long if statements. I could have reduced the tool count if I combined the points mapping into the results mapping, but would have taken more manual effort than I cared for.
@AkimasaKajitani I love the simplicity of the formula you came up with! well done