day2.1 (649B)
- #!/bin/awk -f
- # SPDX-FileCopyrightText: 2022 Haelwenn (lanodan) Monnier <contact+adventofcode@hacktivis.me>
- # SPDX-License-Identifier: BSD-3-Clause
- # (ABC) → Opponent
- # (XYZ) → You
- # +1 for Rock
- # +2 for Paper
- # +3 for Scissors
- BEGIN {
- rock = 1
- paper = 2
- scissors = 3
- loose = 0 # X
- draw = 3 # Y
- win = 6 # Z
- }
- # Rock
- /A X/ { score += loose+scissors }
- /A Y/ { score += draw+rock }
- /A Z/ { score += win+paper }
- # Paper
- /B X/ { score += loose+rock }
- /B Y/ { score += draw+paper }
- /B Z/ { score += win+scissors }
- # Scissors
- /C X/ { score += loose+paper }
- /C Y/ { score += draw+scissors }
- /C Z/ { score += win+rock }
- END { print score }