From e41c655d6ca88c8d3ea8af915634409e1e4a9f46 Mon Sep 17 00:00:00 2001 From: Stefan Forstenlechner Date: Mon, 27 Dec 2021 12:44:24 +0100 Subject: [PATCH] Day 23 (unfinished) --- Day22.cs | 2 +- Day23.cs | 42 ++++++++++++++++++++++++++++++++++++++++++ day23/input | 5 +++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 Day23.cs create mode 100644 day23/input diff --git a/Day22.cs b/Day22.cs index b8a0bac..4eb2205 100644 --- a/Day22.cs +++ b/Day22.cs @@ -1,4 +1,4 @@ -#define Day22 +// #define Day22 #if Day22 using System.Text.RegularExpressions; diff --git a/Day23.cs b/Day23.cs new file mode 100644 index 0000000..82d3a7a --- /dev/null +++ b/Day23.cs @@ -0,0 +1,42 @@ +#define Day23 +#if Day23 + +var lines = File.ReadAllLines("day23/input") + .ToList(); + +var aStack = new Stack(); +var bStack = new Stack(); +var cStack = new Stack(); +var dStack = new Stack(); + +var stackSpace = new Dictionary, int>() {{aStack, 2}, {bStack, 4}, {cStack, 6}, {dStack, 8}}; +var moveCost = new Dictionary() {{'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, 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 \ No newline at end of file diff --git a/day23/input b/day23/input new file mode 100644 index 0000000..0d24baf --- /dev/null +++ b/day23/input @@ -0,0 +1,5 @@ +############# +#...........# +###B#C#C#B### + #D#D#A#A# + #########