Today and yesterday are very different types of puzzles. This one is a variation on a staple of the AoC series: Conway's Game of Life.
T...
For further actions, you may consider blocking this person and/or reporting abuse
This one went surprisingly well! Still really fast, which I'm loving. And I got to make some more involved macros, which is fun.
Day11.h:
Day11.c:
COBOL, Friday night means I had time to do both parts.
Bit late today as I had to do yesterday first, due to teaching commitments and just to tired to sit down at 10pm to work on it yesterday :-)
Anyway, my first solution, which I won't post here, was very (very) slow, using just lists. So after see looking at comments reddit replaced lists with Map, with the key being the 2D index, it worked out pretty well. Of course, it would have been a lost faster in Rust or C++, just to two arrays, one for the current step, and one for the next, updating in place, and simply switching each step. However I'm trying to do as many of these using Haskell, as most of my other days use Rust and C++ and it's been fun returning to Haskell after quite a while. I feel I've learnt a lot just over these last few days, which always sees like a good outcome. Enough chat, my solution:
I used Haskell. Definitely not the most efficient or optimized solution:
Oops, forgot to post yesterday. Pleased with how this one turned out, especially the unit tests.
Part 1 and 2 js solution, toggle part2 to
true
orfalse
depending on your needsI'm not sure about others but it took a long 4-5 seconds for it to compute part 1, 5-6 for part 2 and I'm very disappointed :(
python solution for both part 1 and 2
OOP in Ruby; I enjoyed writing this!
Ruby. Initially assumed a toroidal grid and wasted a huge amount of time in the process. Part 1:
Part 2:
Well I had a little time while rewatching Buffy this evening with the kids and inspired by E. Choroba, I wrote a very (very) simple C++ program to generate an annimated GIF showing the process of set allocation. It uses the single header GIF library:
The input is a file which has the width and height on the first two lines, followed by the grid for each step. For example, the example given in the AOC description for today:
As the seats don't move, one can probably optimize the code by precomputing the neighbouring or visible seats, but waiting for 4 seconds was not boring enough for me to try it. So, I just count the number of adjacent or visible seats for each seat and then update the seating map.
Part 1:
Part 2:
Lots of code in this one, TIL about creating my generative iterators in Rust. Made me feel smart :). Boring parsing code is redacted. Full stuff on: github.com/benwtrent/advent-of-cod...
Hi guys!
I tried the problem with go.
Unfortunately I still have a runtime in total of round about 120ms.
Do you have any suggestions for a performance enhancement?
Best regards
My JavaScript walkthrough: