Christmas Eve is here! Don't spend too much time on this one. There's a holiday afoot!
The Puzzle
In today’s puzzle, we've finally reached it to the resort at last. Their lobby is being renovated and we're tasked with flipping tiles on an a hexagonal grid to figure out what the pattern is to look like.
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:25AM 12/24/2020 PST.
Language | Count |
---|---|
Python | 1 |
Haskell | 1 |
Rust | 1 |
Merry Coding!
Top comments (9)
Aww, I'm sad it's almost over. I learned loads about hexagonal grids however from this fantastic page. Rust as ever this year with proper modelling and tests...
That reference is great... thanks!
One of the best things about doing these challenges is forcing you to learn things you might not otherwise need. Next time I have a hex tile problem, even if it's just in AoC, I'll remember there are well trodden techniques to use, even if I've forgotten the details.
Yes, the best part of AoC is how much I've learned.
Since I already implemented cellular automata with Tensorflow in multiple previous days, I re-use it again. Also, luckily I'd done a fair bit of hex grids in game dev before. A small bonus: Python has native support for complex numbers, which can be used to write compact code involving complex arithmetic or, in this case, just using complex numbers to hold a 2-vector.
Well back to Haskell today, although not 100% sure this was a good choice. The problem being that updating an ever growing floor map in part 2 meant that after about 50 iterations it starts to get pretty slow. So much so I had to add some prints, inititally, to check it was actually making progress. However, it was and it kindly got to the right answer. Another issue was that as I'd choosen to use a map that used the position as a key, which for me were complex numbers, then i had to convert to string and back, as Haskell won't allow "real" numbers to have order defined that is needed for maps, at least I could not resolve that issue. Ahh well it still worked out pretty nicely, if not a little on the slow side.
Part 1 JS solution is done, part 2 is coming soon!
Quick one today! Probably could improve efficiency in the Conway section, but it runs pretty quick so I'm good with it. Forgot for a minute that I needed to loop over the white tiles sharing boundaries with my black tiles too!
My JavaScript video walkthrough: