function getPart2Solution () {
const scores = {
match: {
X: {A: 3, B: 0, C: 6},
Y: {A: 6, B: 3, C: 0},
Z: {A: 0, B: 6, C: 3}
},
bonus: {X: 1, Y: 2, Z: 3}
}
const choiceLookup = {
A: {X: 'Z', Y: 'X', Z: 'Y'},
B: {X: 'X', Y: 'Y', Z: 'Z'},
C: {X: 'Y', Y: 'Z', Z: 'X'}
}
return input
.trim()
.split('\n')
.map((token) => token.split(' '))
.map(([opponent, outcome]) => [opponent, choiceLookup[opponent][outcome]])
.map(([opponent, player]) => scores.match[player][opponent] + scores.bonus[player])
.reduce((total, score) => total + score, 0)
}