Day 21 minor cleanup
This commit is contained in:
parent
52d2edc0fe
commit
68d2c20e00
21
Day21.cs
21
Day21.cs
|
|
@ -1,26 +1,17 @@
|
|||
#define Day21
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Channels;
|
||||
using AoC2021;
|
||||
|
||||
#if Day21
|
||||
using AoC2021;
|
||||
|
||||
var states = File.ReadAllLines("day21/input")
|
||||
.Select(l => new State() {pos = int.Parse(l[l.Length-1].ToString()) - 1, score = 0})
|
||||
.ToList();
|
||||
|
||||
// states = new List<State>() {
|
||||
// new State() {pos = 3, score = 0},
|
||||
// new State() {pos = 7, score = 0},
|
||||
// };
|
||||
|
||||
var states2 = states.Select(s => s.Copy()).ToList();
|
||||
|
||||
var bla = Enumerable.Range(1, 3).SelectMany(x =>
|
||||
var diceCombinations = Enumerable.Range(1, 3).SelectMany(x =>
|
||||
Enumerable.Range(1, 3).SelectMany(y => Enumerable.Range(1, 3).Select(z => new {x = x, y = y, z = z})))
|
||||
.Select(p => p.x + p.y + p.z).GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count()); //ForEachAsList(p => Console.WriteLine(p));
|
||||
bla.ForEachAsList(b => Console.WriteLine($"{b.Key}: {b.Value}"));
|
||||
// System.Environment.Exit(0);
|
||||
.Select(p => p.x + p.y + p.z).GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());
|
||||
diceCombinations.ForEachAsList(b => Console.WriteLine($"{b.Key}: {b.Value}"));
|
||||
|
||||
int curPlayer = 0;
|
||||
int dieThrows = 0;
|
||||
|
|
@ -41,8 +32,6 @@ Console.WriteLine(minScore * dieThrows);
|
|||
|
||||
//------------------
|
||||
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
Stack<CompleteState> stack = new Stack<CompleteState>();
|
||||
stack.Push(new CompleteState(0, new StateRec(states2[0].pos, states2[0].score), new StateRec(states2[1].pos, states2[1].score), 1));
|
||||
|
||||
|
|
@ -60,8 +49,6 @@ while (stack.Count > 0) {
|
|||
AddState(Add(curP, 8), cur, p0, p1, winTimes * 3);
|
||||
AddState(Add(curP, 9), cur, p0, p1, winTimes * 1);
|
||||
}
|
||||
sw.Stop();
|
||||
Console.WriteLine(sw.Elapsed);
|
||||
Console.WriteLine(countWin0);
|
||||
Console.WriteLine(countWin1);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue