We're getting close. I can comfortably say that it's Christmas Eve Eve Eve. Three Eves. We Three Eves. Actually, not a bad band name. Sort of a holiday-themed Destiny's Child vibe. Anyways, on to the puzzle.
The Puzzle
In today’s puzzle, we have gotten so bored on our journey that we've inexplicably taught a crab how to play cards. We're playing Combat (which I've played as War). Whoever has the highest card each round takes both cards into the bottom of their deck and play proceeds until someone has all the cards. Good luck!
The Leaderboards
As always, this is the spot where I’ll plug any leaderboard codes shared from the community.
Ryan's Leaderboard: 224198-25048a19
If you want to generate your own leaderboard and signal boost it a little bit, send it to me either in a DEV message or in a comment on one of these posts and I'll add it to the list above.
Yesterday’s Languages
Updated 07:10AM 12/22/2020 PST.
Language | Count |
---|---|
JavaScript | 2 |
Rust | 1 |
Python | 1 |
Haskell | 1 |
Merry Coding!
Top comments (7)
I got there in the end on this one but I have to admit I don't know why. I was storing the complete game state (both players) in a HashSet for recording the history. This passed the tests but gave the wrong answer for the final score. After reading another thread online (the first time I've looked this year!) someone suggested you only need to store the first player's state as this is enough to uniquely identity a game position. That feels like an optimisation, not a logic change but I did it anyway and now it produces the correct answer. I feel bad for writing code I don't understand!
Ah today Haskell was a great choice, had fun and got it done really quick, which was lucky as spent a large amount of the day baking ginger bread houses for the kids to cover in icing and sweets :-)
This one seemed pretty straightforward, so I knocked it out in Python in an effort to get caught up. I forgot about the "no repeats" rule and stared at my terminal recursing infinitely for a while. Also,
deque
was a great idea, but I didn't realize you couldn't slice adeque
in Python, which made copying them partially a bit awkward.A quick bit of python, didn't want to spend too long on it
I got mine done but it runs really slowly (~50s)...I'm pretty sure I did something dumb here. There's a lot of loops and I suspect I accidentally went O(n2) or possibly even O(n3)
In .NET 6 (1s)
My JavaScript video walkthrough: