6 Commits

Author SHA1 Message Date
1fab8c9161 Completed puzzles for 2021 day 23 2022-01-12 14:26:21 +00:00
3ba00ad3eb Separate out Dijkstra implementation
This separates the Dijkstra implementation into its own generic function.

Whilst doing this we can simplify the code and also save yet more memory!

Still don't get correct results for part 2.
2022-01-12 11:31:09 +00:00
a1a7d11583 Separate out Dijkstra implementation
This separates the Dijkstra implementation into its own generic function.

Whilst doing this we can simplify the code and also save yet more memory!

Still don't get correct results for part 2.
2022-01-12 09:30:21 +00:00
a5fc32ed07 Imrpove Puzzle 23-01 by modelling top row correctly.
Previously we modelled the top row as a connected series of nodes and allowed them to connect to each other directly.  This ignored the rule that you have to move directly to the place you want on the top row and then back out of it.

However, that was fine as the lowest cost would imply that.  But it does slow down and give more states to consider.

Instead, model the nodes on the top row as being directly connected to the nodes in the second row.  Add some rules about when you can move from one to the other and use those.

This reduces the number of states we have to consider in total.  And hopefully speeds up the process.
2021-12-24 12:34:00 +00:00
cca3a22a43 Proposed solutions for 2021 day 23
Improve speed by using two sets for State management:

states: Contains all the states we need to visit indexed by state - Cost is ignored.
costs:  Contains all the states we need to visit indexed by cost then state.

This then means the lookup for the minimum cost is fast.
2021-12-24 11:53:57 +00:00
b53002d48a Proposed solutions for 2021 day 23 2021-12-23 19:49:33 +00:00