day2.0 (729B)
- #!/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 (A, X)
- # - 2 for Paper (B, Y)
- # - 3 for Scissors (C, Z)
- # Object(Rock, Paper, Scissors) + 3 if draw or 6 if won, 0 if lost
- /X/ { score += 1 }
- /Y/ { score += 2 }
- /Z/ { score += 3 }
- /A X/ { score += 3 } # Rock-Rock
- /A Y/ { score += 6 } # Rock-Paper
- /A Z/ { score += 0 } # Rock-Scissors
- /B X/ { score += 0 } # Paper-Rock
- /B Y/ { score += 3 } # Paper-Paper
- /B Z/ { score += 6 } # Paper-Scissors
- /C X/ { score += 6 } # Scissors-Rock
- /C Y/ { score += 0 } # Scissors-Paper
- /C Z/ { score += 3 } # Scissors-Scissors
- END { print score }