Xah Talk Show 2022-12-14 Advent of Code Day 2B, in WolframLang, Live Coding
Watch the first 40 min. toy problem vs real life, how to judge code, etc. the rest is solving the advent of code problem plus some other minor rambling.
Clear[xinput, fComputeLine2, x6, xanswer ] fComputeLine2[{x_, y_}] := y 3 + Mod[ x + (y -1) + 3 , 3 ] + 1 xinput = " A Y B X C Z"; x6 = Map[ fComputeLine2, ToExpression[ Partition[ StringSplit[ StringReplace[ xinput, { "A" -> "0", "B" -> "1", "C" -> "2", "X" -> "0", "Y" -> "1", "Z" -> "2" } ] ], 2 ] ] ] xanswer = Total @ x6
- X = 0 → lose = 0 →
x-1+3 % 3
- Y = 1 → draw = 3 →
x
- Z = 2 → win = 6. →
x+1 % 3
to beat enemy:
- 0 → 1
- 1 → 2
- 2 → 0