Spaceship operator - Day 07 - Advent of Code 2023

Sdílet
Vložit
  • čas přidán 6. 12. 2023
  • This video tackles the "Camel Cards" poker puzzle. We’ll parse the input data into Hand objects, modeling ranks, and bids. We can sort hands by type and strength by including the Comparable module and implementing spaceship logic.
    For part 1, we’ll build a card counter and hand typing system, assigning numeric ranks. This lets us multiply bids by position to get total winnings. For part 2's joker rules, we’ll tweak the ranks and add joker offset logic to promote hands.
    The core solution focuses on custom classes and comparable spaceships for sorting. I polish with enumerable pipelines for a concise answer. While not golf code, we end up with readable Ruby leveraging objects, sorting, and clever tricks.
    Advent of Code: adventofcode.com/
    My Solutions: gist.github.com/cjavdev/d15a2...
    Playlist • Advent of Code
    #adventofcode #ruby
  • Jak na to + styl

Komentáře • 3

  • @jeffreyprice3614
    @jeffreyprice3614 Před 5 měsíci +3

    How I handled my jokers was once I got the tally of cards, I removed the jokers from the tally hash and added the number of jokers to the highest card left in the hash and kept the rest of the logic similar to your part 1 implementation.

    • @cjav_dev
      @cjav_dev  Před 5 měsíci +2

      Oh nice! I actually like that approach better than mine!