summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-01-14Puzzle 1: Consolidate 1a/1b programs into `1` with `-p` optionAdam Spragg
Like the later puzzles
2023-01-13Puzzle 22: Solve part 2Adam Spragg
Here we teach the elf how to use the face information to walk around the cube. Finally Just don't ask me to explain this again in 6 months time.
2023-01-13Puzzle 22: Extract all cube faces, even for T-shaped netsAdam Spragg
At the moment, I can't figure out how to break up the long stem of a T-shaped net properly (and other similar nets with 2 or more faces in a straight line), for an arbitrary cuboid. This should be possible, and was something I was hoping to be able to do for this puzzle. That's not happening, so add in a hackish solution that takes advantage of some of the conditions of the Advent of Code rules/input, instead of being a properly general solution. If possible, come back and take this out later.
2023-01-13Puzzle 22: Reorder net faces in array to match their faceidAdam Spragg
This makes it so that, given cube face 0 is in map->faces[0] and pointing north, cube face 1 will be in map->faces[1], cube face 2 will be in map->faces[2], etc..., with their orientations set appropriately. This will allow us to be able to tell where on the cube an elf is, and where they're going if they walk off an edge.
2023-01-13Puzzle 22: Have the map extract and save the net facesAdam Spragg
2023-01-13Puzzle 22: Add ability to find the map outlineAdam Spragg
I need this for working out the shape of the net
2023-01-12Puzzle 22: Add functions for orienting a cubeAdam Spragg
To figure out where you're going on a net (as far as I can figure) you need to be able to tell which faces of a cube are connected to each other, and which direction they are in relative to each other.
2023-01-12Puzzle 22: Remove unneeded variableAdam Spragg
Process command-line options by re-using a different variable than the one we were re-using before.
2023-01-12Puzzle 22: Simplify because map_elem() never returns '\n'Adam Spragg
2023-01-12Puzzle 22: Change coordinate system so that 'y' goes upAdam Spragg
Having 'y' go down was easier with navigating through the memory buffer we were using to store the map, but some of the work we'll have to do with the cube net is easier for me to get my head around with a more traditional coordinate system.
2023-01-12Puzzle 22: Create an abstraction for "map"Adam Spragg
This will help with some future changes
2023-01-12Puzzle 22: Use an `int` to hold the result of fgetc()Adam Spragg
A char won't do.
2023-01-03Puzzle 22: Change where we check for movement special casesAdam Spragg
2023-01-03Puzzle 22: Store elf position as x,y coordsAdam Spragg
Rather than just a linear position in the map buffer
2023-01-02Puzzle 13: Solve part 2Adam Spragg
2023-01-02Puzzle 13: Solve part 1 (finally!)Adam Spragg
2023-01-02Puzzle 22: Store proposed next position as an elfAdam Spragg
That way we will keep a proposed orientation change alongside the position change.
2023-01-02Puzzle 22: Add ability to select "net" map typeAdam Spragg
It doesn't work yet...
2023-01-02Puzzle 22: Allow for moving around changing our orientationAdam Spragg
2023-01-02Puzzle 22: Create "elf" type to hold position and orientationAdam Spragg
This will help when just moving around can change the orientation, as you move over an edge
2022-12-31Puzzle 19: Solve part 2Adam Spragg
2022-12-31Puzzle 19: Don't build a type of robot if we have lots of that resourceAdam Spragg
We obviously have enough of that resource at this time, so there's no need for another robot yet. Drops time by 60% on full 24-round test data (4.6s -> 1.8s)
2022-12-31Puzzle 19: Don't do nothing if we could build all robots.Adam Spragg
The only reason to do nothing would be to save resources to build a robot we can't affort to build yet. But if we have enough resources to build all of them, there's no point in not building any Drops time by 35% on full 24-round test data (7.2s -> 4.6s)
2022-12-31Puzzle 19: Switch default build strategy to "exhaustive"Adam Spragg
2022-12-31Puzzle 19: Solve part 1 (yay!)Adam Spragg
Just generate the output needed by the puzzle.
2022-12-31Puzzle 19: Don't build ore/clay robots when short on timeAdam Spragg
Don't try building ore robots if there are fewer than 10 rounds remaining, or clays robots if there are fewer than 5. It's probably too late for those robots to make a difference? Maybe? (Why 5 and 10 rounds? Just a guess. And it seems to still get the right result) Drops time by 90% on 22-round test data (4.8s -> 0.4s)
2022-12-31Puzzle 19: Never build more robots than neededAdam Spragg
Because we can only build one robot at a time, if the most expensive robot in terms of ore takes 4 ore to build, we'll never need more than 4 ore robots. Because they can always collect enough ore to build one robot of any type per turn. Drops time by 90% on 20-round test data (5.4s -> 0.5s)
2022-12-31Puzzle 19: Use int instead of long for material amounts/robotsAdam Spragg
Drops time by about 20% on 20-round test data (6.6s -> 5.4s)
2022-12-31Puzzle 19: Only build at most one robot per round!Adam Spragg
After reading the rules more carefully, I see we can only build one robot per round! (Not just one robot per material type, one robot!) Doh! This reduces the combinatorial explosion a lot. The exhaustive search has become a lot more feasible, with Blueprint 2 of the test input able to cover 22 rounds in a minute and a half. I shouldn't only need to find some small wins from here to get the 24-round runtime to something sensible.
2022-12-30Puzzle 19: Add an "exhaustive" build strategy.Adam Spragg
As expected, the explosion in permutations makes this prohibitive. With this stragegy, on Blueprint 2 of the test input, for: 10 rounds it takes 0.018s/59,979 iterations 11 rounds it takes 0.070s/1,257,483 iterations 12 rounds it takes 1.292s/59,156,010 iterations 13 rounds it takes 3m2.770s/8,395,942,157 iterations Getting to 24 rounds just isn't feasible with that growth. And I can't figure out how to cull unwanted permutations easily. Going to have to try something else.
2022-12-30Puzzle 19: Allow user to specify build strategyAdam Spragg
2022-12-30Puzzle 19: Allow user to specify number of roundsAdam Spragg
2022-12-30Puzzle 19: Fix debug info for geodesAdam Spragg
2022-12-29Puzzle 19: Move the timing loop into the build functionAdam Spragg
2022-12-29Puzzle 19: Move blueprint id into the blueprintAdam Spragg
2022-12-29Solve puzzle 25 part 1Adam Spragg
2022-12-29Input for puzzle 25Adam Spragg
2022-12-28Solve puzzle 24 part 2Adam Spragg
Phew. Nice that the puzzles for the 24th have been pretty easy
2022-12-28Solve puzzle 24 part 1Adam Spragg
2022-12-28Input for puzzle 24Adam Spragg
2022-12-28Cache nearby elf positionsAdam Spragg
2022-12-28Solve puzzle 23 part 2Adam Spragg
2022-12-28Solve puzzle 23 part 1Adam Spragg
2022-12-27Input for puzzle 23Adam Spragg
Back from Christmas travels, let's see if I can finish the set before new year!
2022-12-22Solve puzzle 22 part 1Adam Spragg
2022-12-22Input for puzzle 22Adam Spragg
(Forgot to commit earlier, doh!)
2022-12-21Solve puzzle 21 part 2Adam Spragg
2022-12-21Solve puzzle 21 part 1Adam Spragg
2022-12-21Input for puzzle 21Adam Spragg
2022-12-20Solve puzzle 20 part 2Adam Spragg
Phew. Nice easy one for today! Caught up now.