:: krowemoh

Thursday | 26 DEC 2024
Posts Links Other About Now

previous
next

Advent of Code 2023 - Day 7

2023-12-10
advent-of-code

Day 7 might be my favourite day so far. I missed doing this puzzle on the day it was released and caught up over the weekend. It was a fun puzzle where you had to rank a set of hands of poker. I wrote the logic and I also wrote a sorting function to make real poker hands out of them. I had misread the puzzle, the puzzle didn't want to sort the hands themselves, it simply wanted to rank them and then sort them within a rank as the hands were.

This meant that some strange hands like 32222 would beat 2AAAA because 3 is greater than 2. Both hands are considered 4 of a kind however the strength of the 4 of a kind doesn't matter, just the order of the hands themselves. I had to back out my sort logic and let hands just be.

I also really like how I figured out the ranking logic, I simplified my logic and now I think I get ranking poker hands more. There should simply be a function to get the power of hand and then you can order the hands by it.

The other thing was that because I was doing this in BASIC, I needed to simplify how things were compared. Instead of trying to add special logic to handle the face cards, I translated them into specific characters so that comparisons would juust work without issue. This was something I would only do because this is BASIC, in any other language you would create an object and use the value parameter to sort the cards.

Day 7