Day 23 (unfinished)

This commit is contained in:
Stefan Forstenlechner 2021-12-27 12:44:24 +01:00
parent 05c9339028
commit e41c655d6c
3 changed files with 48 additions and 1 deletions

View File

@ -1,4 +1,4 @@
#define Day22
// #define Day22
#if Day22
using System.Text.RegularExpressions;

42
Day23.cs Normal file
View File

@ -0,0 +1,42 @@
#define Day23
#if Day23
var lines = File.ReadAllLines("day23/input")
.ToList();
var aStack = new Stack<char>();
var bStack = new Stack<char>();
var cStack = new Stack<char>();
var dStack = new Stack<char>();
var stackSpace = new Dictionary<Stack<char>, int>() {{aStack, 2}, {bStack, 4}, {cStack, 6}, {dStack, 8}};
var moveCost = new Dictionary<char, int>() {{'A', 1},{'B', 10},{'C', 100},{'D', 1000}};
var spaces = Enumerable.Repeat('.', 11).ToArray();
foreach ((var stack, var space) in stackSpace) {
int pos = 2;
while (pos < lines.Count && lines[pos][space+1] != '#') {
stack.Push(lines[pos][space+1]);
pos++;
}
}
Console.WriteLine("adsf");
long Solve(Dictionary<Stack<char>, int> stackSpace, char[] spaces) {
if (spaces.Any(c => c != '.')) {
}
// first check that all chars from spaces that can be moved to its corresponding stack has been moved
// if possible, call recursive (remember what has been moved and undo after call)
// iterate all stacks, check if stack contains element that does not fit. then move the top most element
// after move, call recursive
// if move is not possible, return int max? each recursive all needs to optimize su-calls to minimum. hand down current minimum to check against? (can be done in second step. solve first?)
}
#endif

5
day23/input Normal file
View File

@ -0,0 +1,5 @@
#############
#...........#
###B#C#C#B###
#D#D#A#A#
#########