Module aoc::year2023::day07

source ·
Expand description

§Camel Cards

The types of each hand are computed from the frequency of the cards ordered in descending order. For example a full house would have 1 card with a frequency of 3 and a second with a frequency of 2, giving [3, 2]. Similarly two pair would be [2, 2, 1]. Array comparisons will sort the hand types in order.

To make comparisons faster the frequencies and the card ranks are packed into a usize:

  • 55222 => 0x3200055222
  • 32T3K => 0x2111032a3d

For part two we add the numbers of jokers to the highest frequency (which could already be jokers!).

  • QQQJA => 0x41000ccc1a

Structs§

Functions§