Module advent_of_code_2023::day_7
source · Expand description
This is my solution for Advent of Code - Day 7: Camel Cards
The bulk of the work is done in parsing the input into Hands. This is done by
parse_input, parse_hand. calculate_hand_type is used during parsing to
pre-calculate the HandType once for use in later sorting. parse_cards_part_1,
parse_cards_part_2 are used to control whether a J is a Joker or a Jack.
total_winnings sorts the hands using Hand::cmp, and enumerates the ranking to get the
puzzle solutions.
Structs
- Hand 🔒A hand of cards, including the list of cards in drawn order, the scoring type, and amount bid
Enums
Functions
- Determine the hand rank of a list of five cards.
- Use part 1 parsing of
JmeaningJack - Use part 2 parsing of
JmeaningJoker - Parse a single line in the format
AKQJT 123 - Parse the puzzle input
- The entry point for running the solutions with the ‘real’ puzzle input.
- Reduce a list of cards to the puzzle solution. This is their place in the ranking when sorted weakest first multiplied by the amount bid.