Expand description

This is my solution for Advent of Code - Day 2 - Rock Paper Scissors

The task was to interpret a strategy guide for a rock, paper, scissors tournament in two different ways, calculating a final score if the guide is followed.

Enums

  • Move 🔒
    Encodes the possible moves a player can make
  • Outcome 🔒
    Encodes the possible outcome of a round

Functions

  • draw_for 🔒
    Given an expected move, what move should be thrown to draw a round
  • loss_for 🔒
    Given an expected move, what move should be thrown to win a round
  • parse_move 🔒
    Parse a part of an input line as a move
  • The line syntax for part 1
  • Parse part of an input line as and expected outcome for a round
  • The kine syntax for part 2
  • Parse a strategy guide, taking the syntax that maps a line in the guide to a Round played so this can be reused in both parts.
  • Calculate the move to make given my opponent’s expected move and a desired outcome
  • The entry point for running the solutions with the ‘real’ puzzle input.
  • score_move 🔒
    Calculate the part of a round score based on the move I threw
  • Calculate the part of a round score based on the round’s outcome
  • Calculate the score for a single round
  • Calculate the sum of the scores for all rounds I layed in
  • win_for 🔒
    Given an expected move, what move should be thrown to win a round

Type Aliases

  • Round 🔒
    A round representing (opponent's move, my move)
  • Tournament 🔒
    My view of a tournament: all the rounds I participate in