Compare commits

30 Commits

Author SHA1 Message Date
a805b5b96a [2k25] Add day 3 2025-12-03 20:56:17 +01:00
533c7437dc [2k25] Add day 2 2025-12-03 20:20:28 +01:00
0c3a8478d4 [2k25] Add day 1 2025-12-01 22:14:56 +01:00
f8843866ca Migrato to .Net 10 2025-12-01 22:13:17 +01:00
69a941d34d Add day 25 2025-01-24 10:19:13 +01:00
d647742ca0 Add day 24 2025-01-24 10:19:13 +01:00
bc79ea9fa6 Add day 23 2025-01-24 10:19:13 +01:00
c0b05d45bc Add day 22 2025-01-24 10:19:13 +01:00
ebd5d67fff Add day 21 2025-01-24 10:19:13 +01:00
217cabac34 Add day 20 2025-01-24 10:19:13 +01:00
0ff21ba937 Add day 19 2025-01-24 10:19:13 +01:00
ed8f30c972 Add day 18 2025-01-24 10:19:12 +01:00
380eeda47b Add day 17 2025-01-24 10:19:12 +01:00
8f8448a0e7 Add day 16 2025-01-24 10:19:12 +01:00
be3fbcd34c Add day 15 2025-01-24 10:19:12 +01:00
ab3ff19db3 Add day 14 2025-01-24 10:19:12 +01:00
10429f3302 Add day 13 2025-01-24 10:19:12 +01:00
5f08adc3cb Add day 12 2025-01-24 10:19:12 +01:00
6e433fcf3d Add day 11 2025-01-24 10:19:12 +01:00
d839ab7ec9 Add day 10 2025-01-24 10:19:12 +01:00
8b46a65d56 Add day 9 2025-01-24 10:19:11 +01:00
ef9892502e Add day 8 2025-01-24 10:19:11 +01:00
9b865a12b1 Add day 7 2025-01-24 10:19:11 +01:00
9920041301 Add day 6 2025-01-24 10:19:11 +01:00
323bb83e56 Add day 5 2025-01-24 10:19:11 +01:00
ca58bd804b Add day 4 2025-01-24 10:19:11 +01:00
bbaa3289f6 Add day 3 2025-01-24 10:19:11 +01:00
83ae67a03a Add day 2 2025-01-24 10:19:11 +01:00
2590458b13 Add day 1 2025-01-24 10:19:10 +01:00
828f9bc3dc Add day 1 2024-06-03 17:29:56 +02:00
23 changed files with 5361 additions and 13113 deletions

View File

@@ -2,14 +2,20 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<PackageReference Include="Spectre.Console" Version="0.45.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.15.8" />
<PackageReference Include="Spectre.Console" Version="0.54.0" />
</ItemGroup>
<ItemGroup>
<None Remove="Inputs\*" />
<EmbeddedResource Include="Inputs\*" />
</ItemGroup>
</Project>

View File

@@ -7,7 +7,13 @@ namespace AdventOfCode;
[MemoryDiagnoser(false)]
public class DayBenchmark
{
private Day Day => new Day15();
private Day Day { get; } = new Day3();
[GlobalSetup]
public void Setup()
{
Day.ReadInput();
}
[Benchmark]
public void Part1()

View File

@@ -1,3 +1,5 @@
using System.Reflection;
namespace AdventOfCode.Days;
public abstract class Day
@@ -5,9 +7,19 @@ public abstract class Day
public abstract int Number { get; }
public abstract string Name { get; }
protected string Input { get; private set; } = null!;
public abstract void RunPart1(bool display = true);
public abstract void RunPart2(bool display = true);
public void ReadInput()
{
using var inputStream = Assembly.GetExecutingAssembly()
.GetManifestResourceStream($"AdventOfCode.Inputs.Day{Number}.txt")!;
Input = new StreamReader(inputStream).ReadToEnd();
}
public override string ToString()
{
return $"Day {Number}: {Name}";

File diff suppressed because it is too large Load Diff

View File

@@ -1,287 +0,0 @@
using Spectre.Console;
namespace AdventOfCode.Days;
public class Day10 : Day
{
public override int Number => 10;
public override string Name => "Cathode-Ray Tube";
public override void RunPart1(bool display = true)
{
int cycle = 1;
int x = 1;
long sum = 0;
// Increment sum when needed
void IncrementCycle()
{
cycle++;
// Check for signal stength at the start of a cycle
if ((cycle + 20) % 40 == 0)
{
sum += x * cycle;
}
}
foreach (var line in Input.ReadAllLines())
{
// noop
if (line == "noop")
{
// noop finished, go to next cycle
IncrementCycle();
}
// addx
else
{
var split = line.Split(' ');
var v = int.Parse(split[1]);
// Prepare addx
IncrementCycle();
// addx finished, add to x and then go to next cycle
x += v;
IncrementCycle();
}
}
if (display)
{
AnsiConsole.MarkupLine($"[green]Sum of signal strengths: [yellow]{sum}[/][/]");
}
}
public override void RunPart2(bool display = true)
{
// Setup the CRT
const char litPixel = '#';
const char darkPixel = '.';
const int rowCount = 6;
const int columnCount = 40;
var crt = new char[rowCount, columnCount];
var crtCanvas = new Canvas(columnCount, rowCount);
// Now cycle is the position where the CRT is drawing (need to offset by 1 in the grid)
int cycle = 1;
// x is the position of the sprite
int x = 1;
// Draw first pixel
crt[0, 0] = litPixel;
crtCanvas.SetPixel(0, 0, Color.Red);
// Increment sum when needed
void IncrementCycle()
{
cycle++;
// We're done drawing the crt
if (cycle > 240)
{
return;
}
// Draw a white or black pixel
int row = (cycle - 1) / columnCount;
int column = (cycle - 1) % columnCount;
// The CRT is drawing on the sprite
if (column == x - 1 || column == x || column == x + 1)
{
crt[row, column] = litPixel;
crtCanvas.SetPixel(column, row, (cycle + row) % 2 == 0 ? Color.Green : Color.Red);
}
else
{
crt[row, column] = darkPixel;
crtCanvas.SetPixel(column, row, Color.Black);
}
}
foreach (var line in Input.ReadAllLines())
{
// noop
if (line == "noop")
{
// noop finished, go to next cycle
IncrementCycle();
}
// addx
else
{
var split = line.Split(' ');
var v = int.Parse(split[1]);
// Prepare addx
IncrementCycle();
// addx finished, add to x and then go to next cycle
x += v;
IncrementCycle();
}
}
// Print the CRT
if (display)
{
AnsiConsole.Write(crtCanvas);
}
}
#region Input
public const string Input =
"""
noop
noop
addx 15
addx -10
noop
noop
addx 3
noop
noop
addx 7
addx 1
addx 4
addx -1
addx 1
addx 5
addx 1
noop
noop
addx 5
addx -1
noop
addx 3
noop
addx 3
addx -38
noop
addx 3
addx 2
addx 5
addx 2
addx 26
addx -21
addx -2
addx 5
addx 2
addx -14
addx 15
noop
addx 7
noop
addx 2
addx -22
addx 23
addx 2
addx 5
addx -40
noop
noop
addx 3
addx 2
noop
addx 24
addx -19
noop
noop
noop
addx 5
addx 5
addx 2
noop
noop
noop
noop
addx 7
noop
addx 3
noop
addx 3
addx -2
addx 2
addx 5
addx -38
noop
noop
noop
addx 5
addx 2
addx -1
addx 2
addx 30
addx -23
noop
noop
noop
noop
addx 3
addx 5
addx -11
addx 12
noop
addx 6
addx 1
noop
addx 4
addx 3
noop
addx -40
addx 4
addx 28
addx -27
addx 5
addx 2
addx 5
noop
noop
addx -2
addx 2
addx 5
addx 3
noop
addx 2
addx -25
addx 30
noop
addx 3
addx -2
addx 2
addx 5
addx -39
addx 29
addx -27
addx 5
noop
noop
noop
addx 4
noop
addx 1
addx 2
addx 5
addx 2
noop
noop
noop
noop
addx 5
addx 1
noop
addx 2
addx 5
addx -32
addx 34
noop
noop
noop
noop
""";
#endregion
}

View File

@@ -1,233 +0,0 @@
using System.Collections.Immutable;
using Spectre.Console;
namespace AdventOfCode.Days;
public class Monkey
{
public int Number { get; }
public long InspectionCount { get; private set; }
private readonly Queue<long> _items;
private readonly Func<long, long> _operation;
private readonly long _testDivider;
private readonly int _testFailMonkey;
private readonly int _testSuccessMonkey;
public Monkey(int number, IEnumerable<long> items, Func<long, long> operation, long testDivider, int testFailMonkey, int testSuccessMonkey)
{
Number = number;
_operation = operation;
_testDivider = testDivider;
_testFailMonkey = testFailMonkey;
_testSuccessMonkey = testSuccessMonkey;
InspectionCount = 0;
_items = new Queue<long>(items);
}
public void AddItem(long item)
{
_items.Enqueue(item);
}
public bool ThrowItem(IImmutableList<Monkey> monkeys, bool divideWorry = true)
{
// Return false if there's no item to throw
if (_items.Count < 1)
{
return false;
}
// Increment inspection count
InspectionCount++;
// Take next item to throw
var item = _items.Dequeue();
// Apply the operation on worry level
var newValue = _operation(item);
// Divide worry level by 3 before test
if (divideWorry)
{
newValue = newValue / 3;
}
// Even using this simplification, it's still needed to use longs because
// they sometime overflow before being simplified in part 2
newValue = newValue % (2*3*5*7*11*13*17*19);
// Test is a success
if (newValue % _testDivider == 0)
{
monkeys[_testSuccessMonkey].AddItem(newValue);
}
// Test is a fail
else
{
monkeys[_testFailMonkey].AddItem(newValue);
}
return true;
}
}
public class Day11 : Day
{
public override int Number => 11;
public override string Name => "Monkey in the Middle";
public override void RunPart1(bool display = true)
{
const int roundsCount = 20;
var monkeys = ParseMonkeys();
// Do 20 rounds
for (int round = 0; round < roundsCount; round++)
{
foreach (var monkey in monkeys)
{
// Throw items while there's some
while (monkey.ThrowItem(monkeys)) { }
}
}
var topMonkeys = monkeys.OrderByDescending(m => m.InspectionCount).Take(2).ToList();
if (display)
{
AnsiConsole.MarkupLine($"[green]Monkey business: [yellow]{topMonkeys[0].InspectionCount * topMonkeys[1].InspectionCount}[/][/]");
}
}
public override void RunPart2(bool display = true)
{
const int roundsCount = 10_000;
var monkeys = ParseMonkeys();
// Do 10 000 rounds
for (int round = 0; round < roundsCount; round++)
{
foreach (var monkey in monkeys)
{
// Throw items while there's some
while (monkey.ThrowItem(monkeys, false)) { }
}
}
var topMonkeys = monkeys.OrderByDescending(m => m.InspectionCount).Take(2).ToList();
if (display)
{
AnsiConsole.MarkupLine($"[green]Monkey business: [yellow]{topMonkeys[0].InspectionCount * topMonkeys[1].InspectionCount}[/][/]");
}
}
private static IImmutableList<Monkey> ParseMonkeys()
{
var monkeys = new List<Monkey>();
// Split by monkey description
foreach (var monkey in Input.ReplaceLineEndings("\n").Split("\n\n"))
{
var split = monkey.Split('\n');
var numberLine = split[0];
var itemsLine = split[1];
var operationLine = split[2];
var testDividerLine = split[3];
var testSuccessLine = split[4];
var testFailLine = split[5];
// Monkey attributes
var number = int.Parse(numberLine[numberLine.LastIndexOf(' ')..^1]);
var items = itemsLine[(itemsLine.IndexOf(':') + 2)..].Split(", ").Select(long.Parse);
// Read operation
operationLine = operationLine[(operationLine.IndexOf('=') + 2)..];
long? rightOperand = operationLine.EndsWith("old") ? null : long.Parse(operationLine.Split('+', '*')[1].Trim());
Func<long, long> operation = operationLine.Contains('+') switch
{
true => rightOperand is null
? old => old + old
: old => old + (int)rightOperand,
false => rightOperand is null
? old => old * old
: old => old * (int)rightOperand
};
var testDivider = long.Parse(testDividerLine[testDividerLine.LastIndexOf(' ')..]);
var testSuccessMonkey = int.Parse(testSuccessLine[testSuccessLine.LastIndexOf(' ')..]);
var testFailMonkey = int.Parse(testFailLine[testFailLine.LastIndexOf(' ')..]);
monkeys.Add(new Monkey(number, items, operation, testDivider, testFailMonkey, testSuccessMonkey));
}
return monkeys.ToImmutableList();
}
#region Input
public const string Input =
"""
Monkey 0:
Starting items: 89, 95, 92, 64, 87, 68
Operation: new = old * 11
Test: divisible by 2
If true: throw to monkey 7
If false: throw to monkey 4
Monkey 1:
Starting items: 87, 67
Operation: new = old + 1
Test: divisible by 13
If true: throw to monkey 3
If false: throw to monkey 6
Monkey 2:
Starting items: 95, 79, 92, 82, 60
Operation: new = old + 6
Test: divisible by 3
If true: throw to monkey 1
If false: throw to monkey 6
Monkey 3:
Starting items: 67, 97, 56
Operation: new = old * old
Test: divisible by 17
If true: throw to monkey 7
If false: throw to monkey 0
Monkey 4:
Starting items: 80, 68, 87, 94, 61, 59, 50, 68
Operation: new = old * 7
Test: divisible by 19
If true: throw to monkey 5
If false: throw to monkey 2
Monkey 5:
Starting items: 73, 51, 76, 59
Operation: new = old + 8
Test: divisible by 7
If true: throw to monkey 2
If false: throw to monkey 1
Monkey 6:
Starting items: 92
Operation: new = old + 5
Test: divisible by 11
If true: throw to monkey 3
If false: throw to monkey 0
Monkey 7:
Starting items: 99, 76, 78, 76, 79, 90, 89
Operation: new = old + 7
Test: divisible by 5
If true: throw to monkey 4
If false: throw to monkey 5
""";
#endregion
}

View File

@@ -1,333 +0,0 @@
using Spectre.Console;
namespace AdventOfCode.Days;
public class Day12 : Day
{
public override int Number => 12;
public override string Name => "Hill Climbing Algorithm";
public const int EndElevation = 25;
// Color map of elevation: blue -> green -> yellow -> orange -> red
private readonly Color[] _colorMap =
{
Color.Blue1,
Color.DodgerBlue1,
Color.DeepSkyBlue1,
Color.Turquoise2,
Color.Cyan1,
Color.Cyan2,
Color.MediumSpringGreen,
Color.SpringGreen1,
Color.SpringGreen2_1,
Color.Green1,
Color.DarkOliveGreen2,
Color.GreenYellow,
Color.DarkOliveGreen1,
Color.Yellow2,
Color.Khaki1,
Color.Yellow1,
Color.NavajoWhite1,
Color.LightGoldenrod2_1,
Color.Gold1,
Color.SandyBrown,
Color.Orange1,
Color.DarkOrange,
Color.OrangeRed1,
Color.IndianRed1,
Color.HotPink,
Color.MediumOrchid1_1
};
private (int x, int y) _end;
private (int x, int y) _start;
public override void RunPart1(bool display = true)
{
var map = ParseMap();
var canvas = DrawMap(map);
// Test all possible solutions
var minimumPathLength = ExplorePath(map);
// Draw solution path
foreach (var (x, y) in minimumPathLength.path)
{
canvas.SetPixel(x, y, Color.White);
}
if (display)
{
AnsiConsole.Write(canvas);
AnsiConsole.WriteLine();
AnsiConsole.MarkupLine($"[green]Minimum path length: [yellow]{minimumPathLength.length}[/][/]");
}
}
public override void RunPart2(bool display = true)
{
var map = ParseMap();
var canvas = DrawMap(map);
// Test all possible solutions
var minimumPathLength = FindNearestStart(map);
// Draw solution path
foreach (var (x, y) in minimumPathLength.path)
{
canvas.SetPixel(x, y, Color.White);
}
if (display)
{
AnsiConsole.Write(canvas);
AnsiConsole.WriteLine();
AnsiConsole.MarkupLine($"[green]Minimum path length: [yellow]{minimumPathLength.length}[/][/]");
}
}
private (int length, List<(int x, int y)> path) ExplorePath(byte[,] map)
{
var height = map.GetLength(0);
var width = map.GetLength(1);
// Store seen positions with number of steps to reach this position
var exploredPositions = new Dictionary<(int x, int y), int>();
var toExplore = new Queue<(int x, int y, int elevation, int steps, List<(int x, int y)> path)>();
var pathLengths = new List<(int length, List<(int x, int y)> path)>();
toExplore.Enqueue((_start.x, _start.y, 0, 0, new()));
// Explore all possible path
while (toExplore.Count > 0)
{
var (x, y, previousElevation, steps, path) = toExplore.Dequeue();
// If we went out of bound
if (x < 0 || x >= width || y < 0 || y >= height)
{
continue;
}
// If new elevation is too high
var newElevation = map[y, x];
if (newElevation - previousElevation > 1)
{
continue;
}
// If new path is not better than old path, just skip
if (exploredPositions.TryGetValue((x, y), out var oldSteps))
{
if (oldSteps <= steps)
{
continue;
}
}
// Mark this position as explored and store required number of steps to reach it
exploredPositions[(x, y)] = steps;
// Update path
var newPath = new List<(int x, int y)>(path) { (x, y) };
// If we found the end, note that we could end the search here since it's a bfs, there can't be
// any shorter path to this point
if ((x, y) == _end)
{
pathLengths.Add((steps, newPath));
continue;
}
var nextPositions = new (int x, int y)[]
{
(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)
};
foreach (var nextPosition in nextPositions)
{
toExplore.Enqueue((nextPosition.x, nextPosition.y, newElevation, steps + 1, newPath));
}
}
return pathLengths.MinBy(p => p.length);
}
private (int length, List<(int x, int y)> path) FindNearestStart(byte[,] map)
{
var height = map.GetLength(0);
var width = map.GetLength(1);
// Store seen positions with number of steps to reach this position
var exploredPositions = new Dictionary<(int x, int y), int>();
var toExplore = new Queue<(int x, int y, int elevation, int steps, List<(int x, int y)> path)>();
var pathLengths = new List<(int length, List<(int x, int y)> path)>();
toExplore.Enqueue((_end.x, _end.y, EndElevation, 0, new()));
// Explore all possible path
while (toExplore.Count > 0)
{
var (x, y, previousElevation, steps, path) = toExplore.Dequeue();
// If we went out of bound
if (x < 0 || x >= width || y < 0 || y >= height)
{
continue;
}
// If new elevation is too low, skip
var newElevation = map[y, x];
if (previousElevation - newElevation > 1)
{
continue;
}
// If new path is not better than old path, just skip
if (exploredPositions.TryGetValue((x, y), out var oldSteps))
{
if (oldSteps <= steps)
{
continue;
}
}
// Mark this position as explored and store required number of steps to reach it
exploredPositions[(x, y)] = steps;
// Update path
var newPath = new List<(int x, int y)>(path) { (x, y) };
// If we found a possible start, same as in the 1st part, we could stop here
if (newElevation == 0)
{
pathLengths.Add((steps, newPath));
continue;
}
var nextPositions = new (int x, int y)[]
{
(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)
};
foreach (var nextPosition in nextPositions)
{
toExplore.Enqueue((nextPosition.x, nextPosition.y, newElevation, steps + 1, newPath));
}
}
return pathLengths.MinBy(p => p.length);
}
private byte[,] ParseMap()
{
var lines = Input.ReadAllLines().ToArray();
var lineCount = lines.Length;
var columnCount = lines[0].Length;
var map = new byte[lineCount, columnCount];
for (int i = 0; i < lineCount; i++)
{
var line = lines[i];
for (int j = 0; j < columnCount; j++)
{
var elevation = line[j];
map[i, j] = elevation switch
{
'S' => 0,
'E' => EndElevation,
_ => (byte) (elevation - 'a')
};
// Store the end
if (elevation == 'E')
{
_end = (j, i);
}
// Store the start
if (elevation == 'S')
{
_start = (j, i);
}
}
}
return map;
}
private Canvas DrawMap(byte[,] map)
{
var height = map.GetLength(0);
var width = map.GetLength(1);
var canvas = new Canvas(width, height);
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
canvas.SetPixel(x, y, _colorMap[map[y, x]]);
}
}
return canvas;
}
#region Input
public const string Input =
"""
abccccccaaccaaccccaaaaacccccaaaaccccccccccccccccccccccccccccccccaaaaaaaaaaaaaaaaaaaccccccccccccccccaaaccccccccccccaacccccccccccccccccccccccccccccccccccccccccaaaa
abaaaaccaaaaaccccaaaaaccccccaaaaccccccccccccccccccccaaacccccccccccaaaaaaaaaaaaaaaaaaccccccccccccccccaaaaccccccaaacaaccccccccccccccccccccccccccccccccccccccccaaaaa
abaaacccaaaaaaaacaaaaaacccccaaaaccccccccccccccccccccaaaaacccccccccaaaaaaaaaaaaaaaaacccccccccaaccccaaaaaacccccccaaaaaccccaaccccccccccccccacccccccccccccccccccaaaaa
abaaacccccaaaaaccccaaaaccccccaaacccccccccccccccccccaaaaaccccccccccaaaaaacacaaaaaacccccccccccaaccccaaaaacccccccccaaaaaaccaaaaaaccccccccccaaaccccacccccccccccaaaaaa
abaacccccaaaaaccccaacccccccccccccccaaaaacccccccccccaaaaacccccccccaaaaaaaaccaaaaaaacccccccaaaaaaaaccaaaaacccccccaaaaaaaccaaaaacccccccccccaaacccaaaccccccccccccccaa
abaaacccaaacaacccccccccccccccccccccaaaaaccccccccccccaaaaacccccccaaaaaaaaaccaaccaaacccccccaaaaaaaaccaacccccccccaaaaaaccaaaaaaccccccccccccaaaacaaaaccccccccccccccaa
abaaacccccccaaccccccccccccccccccccaaaaaaccccccccccccaaccccccaacccaaaccaaaaccccccaacccccccccaaaacccccccccccccccaacaaaccaaaaaaaccccccccccccajjjjjjjcccccccccccccccc
abcaacccccccccccccccccccccccccccccaaaaaaccccccccccccccccccccaaaaccccccaaaaccccccccccccccaacaaaaaccccccccccccccccccaaccccaaaaaacccccccccccjjjjjjjjjcccccaaaccccccc
abccccccccccccccccccccccccccccccccaaaaaaccaaccccccccccccccaaaaaacccccccaaacccccccccccaacaaaaaaaaccccccccccccccccccccccccaaccaaccccccccaiijjjjojjjjcccccaaacaccccc
abcccccccccccccccccccccccaaacccccccaaacacaaacccccccccccccccaaaaccccaaccccccccccccccccaaaaaaacccaccccccccccccccccccccccccaacccccccccccaiiijjooooojjkccaaaaaaaacccc
abccccccccccccccccccccccaaaaccccccccccaaaaaccccccccccccccccaaaaacccaaaaaccccccccccccccaaaaaacccccccccccccccccccccccccccccccccccccciiiiiiiioooooookkkcaaaaaaaacccc
abccccccccccccccccccccccaaaaccccccccccaaaaaaaacccccccccccccaacaaccaaaaacccccccaaacccaaaaaaaaccccccccccccccccccccccccccccccccccchiiiiiiiiooooouoookkkccaaaaaaccccc
abcccccccccaaccccccccccccaaaccccccccccccaaaaacccccccccccccccccccccaaaaaccccccaaaacccaaaaacaacccccccccccccaacaacccccccccccccccchhhiiiinnnooouuuuoookkkccaaaaaccccc
abcccccccccaaacccccccccccccccccccccccccaaaaacccccccccccccccccccccccaaaaacccccaaaaccccccaaccccccccccccccccaaaaacccccccccccccccchhhnnnnnnnnouuuuuuppkkkkaaaaaaccccc
abccccccaaaaaaaacccaaccccccccccccccccccaacaaccaacaaccccccccccccccccaacccccccccaaaccccccaacccccccccccccccaaaaacccccccccccccccchhhnnnnnnnnntuuxuuupppkkkkkacccccccc
abccccccaaaaaaaacacaaaacccccccccccccccccccaaccaaaaacccccccccccccccccccccccccccccccccccccccccccccccccccccaaaaaacccccccaacccccchhhnnnnttttttuxxxuuppppkkkkkcccccccc
abcccccccaaaaaaccaaaaaaccccccccccaaccccccccccaaaaaccccccccccccccccccccccccaaacccccccccccccccccccccccccccccaaaaccaaccaaacccaaahhhnnntttttttuxxxxuupppppllllccccccc
abcccccccaaaaaacccaaaacccccccccaaaaaaccccccccaaaaaacccccccccccccccccccccccaaacccccccccccccccccccccccccccccacccccaaaaaaacaaaaahhhppntttxxxxxxxxuuuuvpppplllccccccc
abcccccccaaaaaacccaaaacccccccccaaaaaacccccaaaaaaaaaccccccccccccccccccccaaaaaaaacccccccccccccccccccccaaaccccccaacaaaaaaccaaaaahhhpppttxxxxxxxxyuuvvvvvppplllcccccc
abcccccccaaccaacccaacaccaaaaccccaaaaacccccaaaaaaaaaccccccccccccccccccccaaaaaaaacccccccccccccccccccccaaacaaaaaaaccaaaaaaaaaaaaahhppptttxxxxxxyyyyyyvvvppplllcccccc
SbccccccccccccccccccccccaaaacccaaaaacccccccaaaaaaaaacaaaccccccccaacccccccaaaaaccccccccaaaaacccccccccaaaaaaaaaaaaaaaaaaaaaaaaacgggpppttxxxxEzzyyyyyvvvqqqlllcccccc
abccccccccccccccccccccccaaaacccaaaaacccccccaaaaaaaaccaaaccccccccaaacaaccaaaaaaccccccccaaaaacccccccaaaaaaaaaaaaaaaaaaaaaaaaaaacgggpppsssxxxyyyyyyvvvvvqqlllccccccc
abcccaaaccccccccccccccccaaaccccccccccccccccaaaaaaaaaaaaaccccccccaaaaaaccaaaaaacccccccaaaaaacccaaaccaaaaaccaaaaaaaaaaaacccccccccgggppssswwyyyyyyvvvvqqqqlllccccccc
abcaaaaaccccccccccccccccccccccccccccccccccaaaaaaaaaaaaacccccccaaaaaaacccaccaaacccccccaaaaaacccaaacccaaaaaaaaaaaccccaaacccaaaaacgggppsswwwyyyyyyvvqqqqqlllcccccccc
abcaaaaaaccccccccccccccccccccccccccccccccccaaccaaaaaaaaaaaccccaaaaaaacccccccccccccccccaaaaacccaaacaaaacaaaaaaaaccccaaacccaaaaacggpppsswwwywwyyyvvqqqmmmlccccccccc
abcaaaaaacccccccaacaaccccccccccccccccccccccccccaaaaaaaaaaaccccccaaaaacccccccccccccccccaaaccaaaaaaaaaaacccccccaacccccccccaaaaaacggpppsswwwwwwwwyvvqqqmmmcccccccccc
abcaaaaaccccccccaaaaaccccccccccccccccccccccccccccaaaaaaaacccccccaacaaacccccccccccccccccccccaaaaaaaaaccccccccccccccccccccaaaaaagggoossswwwwrrwwwvvqqmmmccccccccccc
abcaaaaacccccccaaaaaccccccccccccccccccccccccccccaaaaaaacccccccccaaccccccccccccccccccccccccccaaaaaaacccccccccccaaaccccccccaaaaagggooosssssrrrrwwwvqqmmmcccaacccccc
abcccccccccccccaaaaaaccccccccccccccccccccaacccccccccaaaccccccccccccccccccccccccccccccccccccccaaaaaaccccccccccccaaaaccccccaaaccgggooosssssrrrrrwwrrqmmmcccaacccccc
abcccccccccccccccaaaacccccccccccccccccccaaaacccccccacaaacccccccccccccccccccccccccccccccccccccaaaaaaacccccccccaaaaaacccccccccccgffoooooosoonrrrrrrrrmmmccaaaaacccc
abcccccccccccccccaccccccccccccccccccccccaaaacccccccaaaaacccccccccccccccccccccccccccccccccccccaaacaaacccccccccaaaaacccccccccccccfffoooooooonnnrrrrrmmmddcaaaaacccc
abccccccccccccccccccccccccccccccccccccccaaaaccccccccaaaaacccccccccccccccccccccccccaaaccccccccaacccccccccccccccaaaaaccccccccccccffffoooooonnnnnnrnnmmmdddaaaaacccc
abcccccccccccccccccccccccccccccccccccccccccccccccccaaaaaacccccccccccccccccaaaaaccaaaacccccccccccccccccccccccccaacccccccccccccccfffffffffeeeennnnnnmmdddaaaacccccc
abcccccccaaaccccccccaccccccccccccccccccccccccccccccaaaaccccccccccccaaaccccaaaaaccaaaaccccccccccccccccccccccccccccccccccccccccccccfffffffeeeeennnnnmddddaaaaaccccc
abcccaaccaaacccccaaaacccccaacccccccccccccccccccccccccaaacccccccccccaaacccaaaaaacccaaaccccccccccccccccccccccccccccccccccccccccccccccffffeeeeeeeedddddddcccaacccccc
abcccaaaaaaacccccaaaaaaccaaacccccccccccccccccccccccccccacccccccccccaaaaccaaaaaaccccccccccccccccccccccccccaacccccccccaaaccccccccccccccaaaaaaeeeeedddddcccccccccccc
abcccaaaaaacccccccaaaacccaaacaaaccccaaaacccccccccaaacaaaccccccaacccaaaacaaaaaaacccccccccccccccccccccccccaaaccccccccaaaacccccccccccccccccccaaaaeeddddccccccccccccc
abccccaaaaaaaacccaaaaaaaaaaaaaaaccccaaaacccccccccaaaaaaacccccaaacccaaaaaaaaaacccccccccccccccccccccccaaacaaaccccccccaaaaccccccccccccccccccccaaaccccccccccccccaaaca
abcccaaaaaaaaacccaacaaaaaaaaaaacccccaaaaccccccccccaaaaaacaaacaaacaaaaaaaaaacccccccccccccccaaacccccccaaaaaaaaaaccccccaaaccccccccccccccccccccaacccccccccccccccaaaaa
abcccaaaaaaaacccccccccccaaaaaacccccccaacccccccccccaaaaaaaaaaaaaaaaaaaaaaaaccccccccccccccccaaaacccccccaaaaaaaaacccccccccccccccccccccccccccccaaacccccccccccccccaaaa
abccaaaaaaacccccccccccccaaaaaaacccccccccccccccccaaaaaaaaaaaaaaaaaaaaaaaaaaacccccccccccccccaaaacccccccaaaaaaaacccccccccccccccccccccccccccccccccccccccccccccccaaaaa
""";
#endregion
}

View File

@@ -1,731 +0,0 @@
using Spectre.Console;
namespace AdventOfCode.Days;
public abstract class PacketElement : IEquatable<PacketElement>, IComparable<PacketElement>
{
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == GetType() && Equals((PacketElement) obj);
}
public override int GetHashCode()
{
throw new NotImplementedException();
}
public static bool operator ==(PacketElement left, PacketElement right)
{
return left.Equals(right);
}
public static bool operator !=(PacketElement left, PacketElement right)
{
return !(left == right);
}
public static bool operator <(PacketElement left, PacketElement right)
{
return left.CompareTo(right) < 0;
}
public static bool operator >(PacketElement left, PacketElement right)
{
return left.CompareTo(right) > 0;
}
public bool Equals(PacketElement? other)
{
return other is not null && (this, other) switch
{
(IntegerElement leftInteger, IntegerElement rightInteger) => leftInteger.Value == rightInteger.Value,
(ListElement leftList, IntegerElement rightInteger) => leftList.Elements is [var x] && x == rightInteger,
(IntegerElement leftInteger, ListElement rightList) => rightList.Elements is [var x] && x == leftInteger,
(ListElement leftList, ListElement rightList) => leftList == rightList,
_ => throw new ArgumentException("Can only compare lists and integers")
};
}
public int CompareTo(PacketElement? other)
{
return (this, other) switch
{
(IntegerElement leftInteger, IntegerElement rightInteger) => leftInteger.Value.CompareTo(rightInteger.Value),
(ListElement leftList, IntegerElement rightInteger) => leftList.CompareTo(new ListElement(new PacketElement[] { rightInteger })),
(IntegerElement leftInteger, ListElement rightList) => -rightList.CompareTo(new ListElement(new PacketElement[] { leftInteger })),
(ListElement leftList, ListElement rightList) => leftList.CompareTo(rightList),
_ => throw new ArgumentException("Can only compare lists and integers")
};
}
}
public class ListElement : PacketElement, IEquatable<ListElement>, IComparable<ListElement>
{
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == GetType() && Equals((ListElement) obj);
}
public override int GetHashCode()
{
return HashCode.Combine(base.GetHashCode(), Elements);
}
public IList<PacketElement> Elements { get; }
public int Count => Elements.Count;
public ListElement(IList<PacketElement> elements)
{
Elements = elements;
}
public static bool operator ==(ListElement left, ListElement right)
{
return left.Equals(right);
}
public static bool operator !=(ListElement left, ListElement right)
{
return !(left == right);
}
public static bool operator <(ListElement left, ListElement right)
{
return left.CompareTo(right) < 0;
}
public static bool operator >(ListElement left, ListElement right)
{
return left.CompareTo(right) > 0;
}
public bool Equals(ListElement? other)
{
return other is not null && Count == other.Count && Elements.Zip(other.Elements).All(t => t.First == t.Second);
}
public int CompareTo(ListElement? other)
{
if (other is null)
{
throw new ArgumentException("Other can't be null");
}
// Compare elements by elements
for (int i = 0; i < other.Count; i++)
{
// If there's no element in this list anymore, it's that it's lower
if (i >= Count)
{
return -1;
}
// If the two next values aren't equal, return the result, else continue
var compare = Elements[i].CompareTo(other.Elements[i]);
if (compare != 0)
{
return compare;
}
}
// If there's still more elements in this list, it means that it's bigger, else they are equal
return other.Count != Count ? 1 : 0;
}
}
public class IntegerElement : PacketElement
{
public int Value { get; }
public IntegerElement(int value)
{
Value = value;
}
}
public class Day13 : Day
{
public override int Number => 13;
public override string Name => "Distress Signal";
public override void RunPart1(bool display = true)
{
var pairs = ParsePacketPairs();
var sum = 0;
for (int i = 0; i < pairs.Count; i++)
{
var pair = pairs[i];
if (pair.left < pair.right)
{
sum += i + 1;
}
}
if (display)
{
AnsiConsole.MarkupLine($"[green]Right order pair indices sum: [yellow]{sum}[/][/]");
}
}
public override void RunPart2(bool display = true)
{
var packets = ParsePackets();
// Add divider packets
var firstDivider = new ListElement(new PacketElement[] { new ListElement(new PacketElement[] { new IntegerElement(2) }) });
var lastDivider = new ListElement(new PacketElement[] { new ListElement(new PacketElement[] { new IntegerElement(6) }) });
packets.Add(firstDivider);
packets.Add(lastDivider);
var orderedPackets = packets.Order().ToList();
var firstDividerIndex = orderedPackets.IndexOf(firstDivider) + 1;
var lastDividerIndex = orderedPackets.IndexOf(lastDivider) + 1;
if (display)
{
AnsiConsole.MarkupLine($"[green]Decoder key is: [yellow]{firstDividerIndex * lastDividerIndex}[/][/]");
}
}
private static PacketElement ReadElement(ref ReadOnlySpan<char> packet)
{
// This is an integer
if (packet[0] != '[')
{
return ReadInteger(ref packet);
}
// This is a list packet
return ReadList(ref packet);
}
private static ListElement ReadList(ref ReadOnlySpan<char> packet)
{
var list = new List<PacketElement>();
while (packet[0] != ']')
{
// Skip delimiter
packet = packet[1..];
// If it's an empty list
if (packet[0] == ']')
{
break;
}
list.Add(ReadElement(ref packet));
}
// Skip closing bracket
packet = packet[1..];
return new ListElement(list);
}
private static IntegerElement ReadInteger(ref ReadOnlySpan<char> packet)
{
var intEnd = packet.IndexOfAny(',', ']');
var element = new IntegerElement(int.Parse(packet[..intEnd]));
packet = packet[intEnd..];
return element;
}
private static IList<(PacketElement left, PacketElement right)> ParsePacketPairs()
{
var pairs = new List<(PacketElement, PacketElement)>();
foreach (var pair in Input.ReplaceLineEndings("\n").Split("\n\n"))
{
var split = pair.Split('\n');
var leftSpan = split[0].AsSpan();
var rightSpan = split[1].AsSpan();
pairs.Add((ReadElement(ref leftSpan), ReadElement(ref rightSpan)));
}
return pairs;
}
private static IList<PacketElement> ParsePackets()
{
var packets = new List<PacketElement>();
foreach (var packet in Input.ReadAllLines().Where(l => !string.IsNullOrWhiteSpace(l)))
{
var packetSpan = packet.AsSpan();
packets.Add(ReadElement(ref packetSpan));
}
return packets;
}
#region Input
public const string Input =
"""
[[5,[[3,0]],[0,[8,6,9],2,9],[5,6,[2,8,3],[0]],[6,2,[2,6,8],10]]]
[[6,4,[2,[2,2],8,[3,7,0,6,2]]],[4,10]]
[[[6,[10,9,7]],9,[9,[9,0,8,3],[0],3],[8,1]],[2,10,9],[[0,6,[4]],2,[2,3,[6,7,0],[1,4,2]],[[3,7,2],[],0],9],[],[[]]]
[[1,[1,10]]]
[[2,3,[]],[7,[[6,9,9,1,6],[0,3],10,3,[5]],[[]],[9,[],[1,0,0,1,1]]],[7,[1,[3,0],[7,10,8,5,0],2,1],4,7,3],[[5],6,4],[9,3,[4,[0,7,9,9],5,[2,0],[]],[6,[],[4,9]]]]
[[2,[[3,4,7],[7,2,2,6],[8,9,7,7,6],[7,8,1,6,1],[]],[],8]]
[[4,[[9,8,1],2],10,6,[[],[],7]]]
[[9,4,10],[0,[1,[10,4,6],[1],8],[[6,2,7,2,4],[9,3,5,6],[0,3,7],10],3],[[[5,4],2,10],2,9,4,[[6,7,2,3],[6]]],[],[]]
[[0,1],[[7,[10,0,8,1],1,4]],[]]
[[1,3,2,3],[1,[[],7,[6,5,8,7,9],[0,2]],[8],5,[]],[[7,8,[],[8,9,4]],[2]]]
[[7,[[6]],[4,9]]]
[[10],[],[[10,[10,10,5,2,1],[10],5],[4,4],[[2,1],[9]],6],[6,8]]
[[[[],[2,3,7],4],0],[[[6,5,10,2,6],10,[2,7],5,5],7,8,[0]],[[10,1,3,3,[7]],0],[]]
[[[[6,2,2,8],[7,4,9,4],3,[0]],7,10]]
[[6,5,5,1],[8],[]]
[[1,[]],[10],[10,[8,[4]],6,1],[5]]
[[[[1,1,2,4],[7,8,8,7],5,[9,1,7,0,8],[2,10,10,4]],10,[7,[6,10],[6,10,6,9],[0,8,10],7]],[8,[[],[],[1,3,0,5,10],[7,0,7]],1],[]]
[[6,3,[],5],[]]
[[[3],[2,[],[1,10,5,5],[1,0,3,3,1]]]]
[[[6,5,[4]]],[5,10,5,3],[6],[10]]
[[[[],[5,0,8,5,4],[2],0,[]],7,6,10,[7,1,10,9]],[]]
[[[8,[1,2,3]]],[8],[6,9,[3,1,1,[10,10,3,10,0]],3,0],[[[8,7]]]]
[[0,[[0],5,[6,3,3],[10,3,10,9]],4]]
[[],[5],[8],[[[10,8,10,5,3],[3,7,10,9,8],0],[[],[]]]]
[[],[10,[7,3,[6],7],[9,[3],[8],7,[1]],10],[6,9,[9,3],[[4,8,1],[10,1,4,7],7],10],[[],[3]]]
[[[6],5,6,10,6],[[]],[1,[6,10],8,3],[1]]
[[1,3],[10,[2],8,1,[6,6,[5],5,[2]]],[[4]],[],[]]
[[[],[1,0,[8],8,[0,3,6]],1],[[[6,1],8,3,1],1,[6,[6,9,3,8,7]],10,[5,[4]]]]
[[9,[6,2,[],[3,0,2,7]],0],[[[5,4,0],0,[2],[7,3,2,5,1]],9,3]]
[[2,[7,[5,2,4],8,5,[3,0,4,5,4]],0,8]]
[[8,6,3,[[10,1,1,7]],8]]
[[[9,2,5],10,5]]
[[],[6],[[[3,6,3,9]],[[2,0],7,1,[10,10,4,4,10]]]]
[[4,[[6,8,4,9,2],[],5,[10,1]],1,6],[[[4,2,5],4]],[[3,6]],[7,8,[[5,8,9,10],1,[6,8],1,7]]]
[[[[],10,7],[],[1,[]],8,[9,0]],[0,[[6],3,1,[0,7,5]],[[7,6,3,9,3],4,4],[],0],[],[9,2,[9,1,[0,9,4,6],[9,2],10],9]]
[[],[2,5,6,5,8]]
[[[[4,4],5,[7],3,[8,8,4]],2],[]]
[[[[6,5,4,7,1],[0,9,9]],[[7,3,7,6,10],3,[6,4,9,4]],[1,[],[]]],[[7,5,[2,4,1,1]],2,4],[],[[[4,7],[1,7,9],5,[]],4,[[7,5,1,9,10],2,5,[1,2,0,9,9]]],[9,[]]]
[[7,[[8,10,9,4,5],[1,3]],1],[[[1,1],2],[[3]],[[7,9,6,6,8],4,[5]],7],[3],[[9,[3,9],[3,1,0,9,2]],4,5,9,[[1]]]]
[[[4,[9],5],[[2],8,[5,7,0,0],0,9],[[2,1],[],7,[7,1],2],4,7],[[[4,7,0,10,2],[5,5,0,3,6],[10,6,3,3],4,8],2,[[1]],9,9]]
[[[[6,2,4,0]],[],[[8,3,1,5,5],1,7,4,2],5,1]]
[[[],0],[],[4,[[1,6],2,[8,4,1,3,10]],[5,0,[10,1,0]],8,[2,[10,8,4],[6,2,7,10,10],[8,2,4,4],[]]],[[],6],[[4,5,[2],[10,2,2,1],[4,6,5,10]],[5,[],9,[1]],[]]]
[[9]]
[[[],8],[7,[6,4]],[5]]
[[],[[3,5,[1],3,[3]],[5],6,[[7,2,6,9],[1,0,0,1]]],[[[5,5,2,0,10],10,7,8,7],5,7,7,[[],1,[6]]],[[]]]
[[[5,8,10,[9,1,3,2,4],[6,7,0,7,6]],3,[[7],3,9,4,[9]]]]
[[3,1,4,[[6]],[[4,6],1,[4]]],[0],[3,[],7]]
[[7]]
[[4,[[5]],[10,8,5,0]],[4]]
[[7,6,10,[[1],8,0,[10,5,1]]],[[[2,1,6],9,9,[4],9]],[]]
[[7,0,5,3,1],[],[[0,9,[8,4,9]],[7,[10,9,4,1,7],2,6],10,[],10],[]]
[[1,[],[],6,[[],10,3]]]
[[[[1,6]]],[[[5,3,7],[],[10,9,7,3,3],0,[]],3,10,5],[],[10,[2]]]
[[[[1,5],5],[[6],[3,2],9,[2,0,8]],[9,[6,9,4],8,0,6]],[[[8],8,10],0,[],6,[[2,7,8],0,9]],[7,1],[[[0],[9,5,9]],[[2,10]],[]]]
[[1,7,[[9],8,[1,1,8]]],[[[9,10,2,0,1],10],0,[7,[10,10],10],5],[7,1],[9,[[],[7,10]]],[[2,9,8,[0,0],[10,9,4,1]],[5],[[8,6]]]]
[[[[4,7,4],[],6,[5,4]],[],[7,[],[],3],[[9,3,5,1,10],[],[7,2]]],[[6,1],3,[[],[3,2],[],[3],[8,7,3,9]]]]
[[[2],0],[2,[6,1],6,5],[0,[],[[9],[],[],[10,8,6]],[[9,6,8,2,3],8,1,5,1],[[4],2,[]]],[[10,1,0,6,1],6],[4]]
[[1,[[4,10,2],10],[4],6,[[1,0,7],[8,1,9,5,2],6]]]
[[],[9],[[],[[4,4,1,8],3,5]]]
[[[[10,7],6,[]],[[1,3],[8,9,4],8,[],[2,9]],[8,3],10],[7],[8,9,10]]
[[3,[10,[],4],[[8,3],4,6,[0,6,9,3,6],[8,9,5,9]],[10,[7,1,0,1],[7,1,2,1],[],[]]]]
[[7,2]]
[[8,[],2,0],[[1,[10,7],[0],2,0]],[4,0,[10,[0,5,1],[1],[]],6,[9]]]
[[],[6,[[5,1,6,0,5],4],[7,7,[6],8,[2,1]],1,[[3,0]]],[4,10,[[5,10],[4,9,2,1,5],[7,1,5,6]]],[],[1,9,[]]]
[[[[5,7,1,2],[8],[7,0,9,7,3],[4,2,1],1],8,[4,1,[8,6,1,10],[6,8,3,2,0]],[[3],1,[2]]],[[8,[7,10,1,5,2],[1,1],[1,2]],[[0,4],2,1,[4,6,8]],1,0,3],[10,1,[[0,0,7,8,7],3]],[[4,[4],3,7,[]],3,[10,1,5,[9,6,3]],[[3],[2]],[[],1,10,[2,7]]],[[[9],7,3],8,10]]
[[[3]],[[10],2,3]]
[[[10,4],1,[[4,2,5,8],3,6,[6,10,5,5],5],6],[[7,3,4,5],3,[],[]]]
[[[[0,5,8,4],[2,3,9,1],5],[[9,7,1,5,3],6,[4],[9,2]],[]],[10,[4,1,3,2,7]],[2,9,[4,[],8,[8,10,6,10,10]],[5,8,[]]],[10,4,3,3],[]]
[[],[[[0,9,10,9],9]],[3,[[],[10],4,[4,2,7,8]],0,[[9,10,1,2],9,0],[5]]]
[[[[8,2,9,9],9,4,2],[[9,9],0],[9,[4,1],2,[2,5],2]],[]]
[[],[[0,[4,9]],[4,7,[9],7],[[1,8,9,7,5],[1,4],3,[9,1],4],[4,10,[1],[],[]]],[[5,4,2,10,[9,7,0,4]]],[[[0,10],4],1,5,[[10,7,0,8,9],[6,10,6]],1],[[[5,7],7,5,[]],10,[[6,10,1],[0,8,0]],[],6]]
[[7,[[0,5,8,1],[10,10,0,2],[3]],10],[[[0,1,2,7],4],[1,6]],[[[3],[2],[]],6],[[1],[]]]
[[2],[[],2],[3,9],[],[7,[],1,[[4],8,6,[9,4]],9]]
[[7,[[],[2,10,5,10],1,0,[9,2,1]]],[8,[[],0],4,9],[4,[6,3,5],7]]
[[[[5,5,6,3],[2],8,[]],[[10,1,4,7]],8,6],[[9]]]
[[[[8,9],4]],[[[6,0,6],[0,4,2,8,5],2,[5,6,0,9],1],10,4],[]]
[[[[0],10],[[6,2,10,8]]],[],[[[2],10,3],[],2,10,[10,[]]]]
[[[],1,[]],[[],8]]
[[[2,[10,8,8],[7,1,7,1]],7,1,[]],[6,[[5,10,5,6],2],2,[2,2,[6],10,8]],[[[5,1],[7],1],2,2,10]]
[[5,[3,[8,2,10],[3,10,10,10]],2,7]]
[[],[9,1,4,[1]],[10,[[8,9,2,1],8,6,[],6],8,5],[]]
[[[8,5],[[],2,7,[5,0],[10,5,6,8]]]]
[[[]],[[1,1,5,10,[4,0,10,6,1]],[10,[2,4,7,7],[6,0,8,7]],9,0]]
[[[[4,9,6,4,9],2,[5,1,0,1,5]]],[[1,[4,7,5],8,5],[7,[9,4,8,3,7],8,8,[6,8,3,10,2]],[[6],[8],[2,5,8,3],0]],[]]
[[[4,6,[8,2,10],9],[6],5],[[],0,[1,[4,5,9,1],2]]]
[[[],9,[8,6,[4]]]]
[[6,[]],[4,[],[3,[6,8],[1,6,7,6,6]],6],[],[2,5,5]]
[[8,[[5,3],2,2,6,6]],[]]
[[2,[]],[],[[3,9,10],9]]
[[[]]]
[[[9,[8,6,1,5,0],7,[5,0],[5]],[[]]]]
[[7,4,[[6,4,6,5]],[[9,1],[3,0]],4],[0,[[10,4,8]]],[],[],[[6,7],0,[],[]]]
[[9,3,[8],[10,[10],[7,4]]],[1,[[10,9,4],[7,6],[]],10,5,[]],[[5,7,0],[[3,6,2,8,7]],[[2,6],[],[1,3,9,8,8],10,5],6],[10],[[0,3,7],[[7,1,1,2,1],9]]]
[[1,[3,[],[5,3,9,2],[10,5,4,1,7],[1,5,7]]],[[4,[4,0],9,0]],[[1,[9,8,0,6,9]],2,[[7],7,[1],[10]],7],[[0,[],[6],[]]]]
[[6,1,[10,[4,1,3],1,9]],[]]
[[],[],[],[10]]
[[8,[[10],0,1]]]
[[7,2,7,8],[],[6,0,6,4],[[[5,4,5],7],6,[],[]]]
[[],[[[8,2],7,9],4,2],[7,0],[]]
[[0,1,9,7,5],[[[4,1,10]],8,6],[[[8,9,9,10],[6,5],[8,5,3,5]]],[[],8]]
[[[4,5,6,8],[[5,0,7,10,8],0,[],[7,4,9,9,3]],[]],[],[0,5,[6,8]],[4,[2,[0],[10,1,9,7]],8,3],[]]
[[],[]]
[[[4],4,9],[],[[[3,1],[4,2,5,10,1]],3,[[5,1,0,1,2]],10,[7,[10,5,9,9,9],[2,3,4,10],[2,1],9]]]
[[6,[10,[10]],[7,[4,0,4]],[[0,3,10],7]],[[[9,7,2],7,9,[7,4,8,4,9]],2]]
[[7],[[3,[],[5],[0,6]],[[3,10,5]]]]
[[3,[4,7,[9,0,1,1,7]],0],[[8]]]
[[9,4]]
[[9,[[5],2]],[3,3,[4,[9,3,8],0,5],3,7],[9,5,6],[10,9,2,5,1]]
[[[],[6],8],[[[8],9,[5],1],[6],4,6],[[[]],6],[],[5,[8,8,[10],[5,1,5,9],4],[5,7]]]
[[6,[[],2,9,3],7],[4,[[5,9],3,[3,5,5]],7,7],[[],[[2,0,2,9,3],6],[],[[9,6]],2],[5,9,[[],2,[9,10,10],[7,0,4,1],9],9,[[8,2,2]]]]
[[[7,5,[5,10,1,9],[2,9,9,3]],1,[6,9,[7,9,6]],9,[[5,1,9,10,0]]],[6,8,[]],[],[[2,[2,5,4,9,10],[3,3,3],1],7,[2,9],[4,7,7,[5],[1,2,5,9,8]]],[4,[[],[7]],8,2,1]]
[[4,9,3],[6,[],[6,[7,7,9,1,5],[10,4],10],10,3]]
[[[2,3,[7,5,1,0],5,[10,2,0]]],[7,6],[[[1,0,8,10,2],1]],[0],[6]]
[[10,6],[7,10],[[4],[]],[8,[],[[],10,2,10],[[9,3],[6,9,8],[10,2,4,1],8],2]]
[[[],4],[10,8,[3,9,[]],9],[8,5,[],2],[[8,[10,5,7,2,10],[4,10,7,9],[4,4,5]],[[5,4,6]],[],4]]
[[],[0,8,[5,[6,3,0,7],1,9,6],[3,8,[10,3,8,10],4],[8,[10,6,10],10,[],4]]]
[[[[],6,[5,5],8,[0,5,1]],[7,4,4,[4,1,3,0],8],3,[5,6],8],[9,[4]],[[0,[6,5],1],2,[],[],[2,[8,0,2,10,6],1,[5,8,9,9,4]]],[9,9,[],0]]
[[2,[[7,9,8,8,10],[],[4,5]],[[1,10],7,[1,9,1,0]]],[[4,[6,10,1,5],5,6],[],[[4,9,2,3,2],6,[3,0,2,2]],9,[]],[5,[[10,0,10,6,4],1]],[9,[0,[8,2,2],8,[5],4],[]]]
[[[8],[7,6,10]],[2,5,[[9,9,1,2],[],[],2,4],1],[],[[[7,3,8],1,1,0],[[4,8,7,10,3]],6]]
[[],[[9,9,[4,2]],[7,[],9,[3]],[[1,5,0],[9,3,6,1,2]],[[9,9],4,10,1],1]]
[[],[[0,[9,6],[2,4],9,3],[]],[5],[],[6,[[4,1,0,7,7],[]]]]
[[8,10,6,[],4],[[9,7,2,8]],[0,[5,10,[3],[6,5,9],[4,4]],[],6],[[[],2],8,[9,[3],5,[10,1],8],0],[[3]]]
[[[4,5,[],6,[]],[0,6,[2,4]],10],[[1,[10,6,4,10],[10,4]],1,7,10,7],[],[[],[4,10,[9,0]]],[[6,[10,7,0,7,10]]]]
[[3,[3,[4,1,1,10,10],[8,4]],4],[]]
[[10,[10,4,7]],[7,[1,2,[0,8,6,7]]],[4,6,4]]
[[10,10],[[[2,4,4],0],4]]
[[[[10,4],[1,4,7,1]],2],[[[]]],[3]]
[[[[],[5,4,5,9],8,5],[[],0,4,[1,0],6]],[[3],[[],6,7,0,[7,1]],8,7,8]]
[[[[6,6,5,8],[10,2],[4,10,0]]],[[[1],[4],[0,3,5],[0,1]],[6,[0]],8,1],[1,10,8]]
[[[10,3],[6,[2,2],5]],[[10],[],[[7]],[[],3,[0,0,1,8,0],3,[]],2],[],[]]
[[6],[[],7,[[1,2,0,1]]],[[7]]]
[[[[],[],3]],[]]
[[1,[[5,2,1,10]]]]
[[],[6,1,[]],[1,10,5,6,[[1],[10],2,[2],[4,6,10]]],[]]
[[10,[2,[6,9,4,10,7],[5,8],0],8,10,6],[[[4,10,1]],[[7],[7,4,10,0],[7]],10],[],[[2,[0,2,10,10,1],7,8],[9],[1,[0],[2]],[8,7,[]]],[[]]]
[[1,2,3,[3],[]]]
[[[],1,10,3],[],[5,2,0]]
[[10],[5,1,[8,[9,0,9,10]]],[],[[0],[10,10],4,1]]
[[0,[[0,5],5,2,3]]]
[[],[[],5],[],[0]]
[[3,[9,1,3,[0,9,1,4]]],[],[3,6,[3,10,6]]]
[[9,[[],[7,6],[9],1,10],7,[[4,0],[7],[1]],[1,1,3,[4,5,3,10],1]],[7,4,[[2,9,1,9,3],5,[4]],[8],8]]
[[[[4,5,7],[0],6,[6,7]],8,4]]
[[4,3,[[7,4,6],0,2]],[3,3,8,[[5,5,1,8],[8,2,3],7,3,10],7]]
[[[[7],3,7],0,7,2],[7,[[4,6,8,2,4]],[[6,6,5],[4,4,5,6,6]],[],5],[10,9],[]]
[[2,[[6,2,7,5,7],5,1,3],8],[5,[8,[5,9,8],[],[7,5,3],[4,9,0,2]]]]
[[[2]],[3,[0]],[9,10,2,[],[[7,0,8],4]]]
[[[6,[],7],6,5,9,7],[9,[5,[10,1]],[6],3],[0],[4,4,9,7,[3,6,3,8]]]
[[6,0]]
[[4],[[[4,6],[4,10,3],2,[]],3]]
[[6,8],[[],[5,8,7,3,[]],2,[5,10,[0,5]]],[10,[3,7,[0,5,6,3],1,[9,4,5,1]],5],[[],[7,0,0],[7,6],[7,[7,3,1,1,1],0],[[],8,[]]]]
[]
[[[1,[6]]]]
[[[8,[],[6,9,0,9,7],3,0],4,5,5,[[],8]],[0,5,7,[10,9,[]]],[],[[],[10],[5,8,7]],[6,[[6,10,1],0,[4,9,8,4,7],6,[0,4,9,2]],[5,[1,5,7,1]],3]]
[[10,[0,1,[10],[]],[]],[[8,6],4,9,8,0],[5,[[3,0,6,7],1],4,8],[5,[8,[3]],9,3,[[10,5]]]]
[[[[1,10],[5],[6,2,2],5],[8,5,8,[6,0,0],3]],[]]
[[1,[9,[3,6,3,9]],[[10,4,2],4,4],[[5,10,4]]],[2,[[10],3],[6,[],[2,10],1,[2,4,6,8]],[8,[8,8,9,2],[],7,[2]],[[10,5,5,10],[3,0,10,2,6],[2,2,7,8]]],[[[6,7,1],[8,7],[4,4,4,4],[],9],3,9,0],[[4,2,[2,3],0],[[10],8,1,5]]]
[[[],[10,[2,10,8]]],[]]
[[2,9,4,2,[[2,6,4,9],[10,4,4],[],0,[]]],[[[9,0,9,5],[0,1,0,6,10],[10,2,0,6],10]]]
[[[],7,[3,9,[],2,[2]],10],[],[7,1,[[4,1],[],[5,3,1,8,2]],4,4]]
[[10,[[6],[10,8,1,5],[2,3],3],[[6],8],[5,[4,6],[5,2]],[[8,8,2]]],[2],[[[],[5,3,7],5,[8,2,6]]],[[[2]]]]
[[10,8,9,4,[8,[],8]],[5,7],[]]
[[5],[],[[[1,8,0,8],[1,7,4],5,[]],[],[[]],[2,8,[6],10,10]],[[[0],9,[],[1,0]],10,7,3]]
[[3,[],5,[[10],[9],5],[[10,3,6,9],[8,7],2]],[8,9],[7,[]],[[5],[],8,0]]
[[10,[[9,2,3,7],10,[3,8,4,3]],[10,[3],[4,4]],[2]],[],[3,[7,[9,8,10,10,1],10,[10],1],[7,8,6,[4,8,7],2],6],[[[10]],[[10,7,1],2],0,[[]],8],[]]
[[3,0,1,[7,[0,7,5,2],[],[],[6,5,0]]],[],[],[10],[9,5,[]]]
[[0,8,[],[[1,0],[5,8,3]],[9,8,10]]]
[[],[8,[]]]
[[[7,9],[]],[],[[[1,10,3,8,4]],[9]],[]]
[[[],6,[4,1],2],[9,10],[6,0,1,3],[3,[],[],[7,2]]]
[[[10,[],8,9,[0,1,7,3]],[[10,4,10]]],[],[[5,[5,7,6,7],5,4],3,8,[6,[],[3,2,10],[5,6,2,7]],8],[7,[[9,7,2],8,3,0,9],[5,4,4],7]]
[[[]],[],[2,[],0],[[2,[],4,4]],[[10,[4,7],[1,3,2,4,2]],[],[6,[8,1,3,2],2],6,[5,10,[8,10,6,8,2],6,[]]]]
[[[[7,6,1,3],8,[]],3,1,[0,[5,0,9,8],4,9]],[[[3,10,5,8],[2,2,4],[9,7,6],[7,7,10],0],5,[[0],[4,9,3],3,1,1],[[9],6,5],[]]]
[[3,1,[6,[9,0,3],[2,9,1,2,7],2,[9,9,5]],[0,0,0],3],[8,4,[[2,10,9,6,2],0,[7,5]],[7,2,[9]]]]
[[[10,[],[1,9,4],[0,7,10]],10,10,[[],[7,1,1,9],[4,5,7,2,0],9]],[[[8,7,7,7,10],2,9],[],[[4,10,6,6],[]]],[]]
[[[[],8,[6,0,1],9,9],3],[],[]]
[8,3,10,5]
[8,3,10,5,4]
[[[10,8,1,6],9],[4],[[8],10,[[1,3,2,10],[1,1,8,8,4],10,6]],[9,2],[[[8,9],5,9]]]
[[[[1,5,1,8],[3,6],5],7,10,7,4],[[9,4,6,5,9],[[0],3,[2,2,10,1,1],1],[2,2,[2,10,7],5,10]],[7,6,[4],[[],3,10]]]
[[4,[],[9],7],[5],[[7]],[8,[[3,9,10],10,[4,4,1,7],[7,1,0]],[[2,3,1,7,10],1],5],[9,10,9,[]]]
[[1,1,8,1],[]]
[[[[0,9,3,8],9]],[7,[[8,7,6],4,1,5,[10]],2,[5,[9,6,4,9],[6,7,5,8],10]],[[5,4],8,1,8],[]]
[[7,10,10,[[2,6,6],2],[[]]],[],[5,7,[1,[]],[[4,8,7]],1]]
[[9],[2],[],[]]
[[[],[0,1,4,4],[],[[10,8,8,4],9,[0,2,4,6],[],[7,2,8,9]]],[6,[[2,5,5,8],6,1,[7,1,7,2],[6,9]],[[4,5,6],5,4]],[[]],[],[4,4,[[9],[],9,0,2]]]
[[],[[0,[10,3,3],4,5],[6,9,4]]]
[[9,[[],2,[1],[4,4,6]],[[9],[6,5,2],[6,3,7,4],4],[]],[2],[],[[[2,7],[1,1,10,2,9],7]],[[],[[10,6,4,3],[]],0,[4],[[4],1,10,5]]]
[[[[3],5],[7,9,10]],[2,[1,7,8,[3]],[]],[]]
[[7,6,[],0],[],[[[7,6],[10],1,2,10],1,1,[6,10],[[4,10,4]]],[0,[],[],8,[[5,6,0,1,0]]],[6]]
[[3,[9],[2,[5,0,5,8],[],4],[9,[8],[2,5,4]],[2,[4,7,2],[10,0,3,8,8]]],[[10,2],7,3,9,[[4],1,[1,9,6,9],10,10]],[1],[4,4],[[[7,1],1],10]]
[[[[4,2,1,3],7,[6,0,9,6,8],[3,0,10],8],6,[],3],[[[6],[0,10,5,4,6],7],10,[9,7,[10,3,0,4,0],2,[9,4,2,5]]],[3,[0],[[9,0,1,6,1]]],[[4,1,8,8],[[5,0,6,3,8],[7,8,7],7,[10,6,5]],5,[0],[[],9,9]],[[5]]]
[[[6,[0],[0]],9,[10,7,[10,1,6,8],10],[[],3,2,9],3],[7]]
[[[[9],[8,5,4,6]],10,[[9,6],4,5],6,4],[[10,[]],10,2],[],[[[8,10,9],7,0],[[4],[5,9,8,1,2]],[[8],[10,9,3],[2,6,3,2,6],1],[[6,8],[5,5,4],3]],[[8,1],[5,10],6,0,1]]
[[8,[0,1,6,6,8]],[],[[1,9,2,[4,5,2,4]],4,[],[7,1,7],7]]
[[[7,[7,1],4,10],5,5],[[[1,6,8,9,2],[4],[5,5,7]],1,10,[0,[10,6],3]],[],[[[6],[6,2,0,10]],[[6,6,4,1,3],1],[]],[1,[[7,2],5],[],[2,8,10,[10,1,2,2],4]]]
[2,0,1,0,6]
[2,0,1,0]
[[],[5,[],3,[[1,9,3]],2],[[[],[3,2,3,2,7],[1,10,6,3,9]],1,8]]
[[6],[[[1,0,6],[6,4]],7,1,[2,[5]],7]]
[[9,0,4]]
[[1,10,5,9,[5,5]],[[[3,8,10,8],0,[4],[8],[9,7]]],[[[1,5,4],10],9],[4,[[5,2,8,8],[10,5]],4]]
[[7,6]]
[[[],[[10],0,8],0],[1,5]]
[[[[2],4,[8,7,7,0,4],[3],7],[],[[3,6,6,1]],6],[[[7,0]],1,[1]],[[0,10,[1,0,5],[0,5]],8,4,[9],[0]],[[3,0]],[9]]
[[],[[[0,6,6]],[[8]],3,[1],9]]
[[[4,[0,2,0],8],[[5,10,6,6],[2]]],[],[]]
[[0,6,4],[8,[5,[]],[[9,3],[9],[2,5,0]]],[[10,8,2,[3,0,4,9]],[6,6,5],[4,[],5,9],9],[[[5,0,10,5],5,3],6,4]]
[[0,4,[],4]]
[[[1,[]],6,9,[[4,0],[]]]]
[[0,[[1],10,[4,7],4]],[[10],1,[3],6],[[[7,2,0,7,0],9,[0,8,4],1,6],[[9,2,0]],8,6,[10,8]],[[],10,[9,[8,5,0]],[10],3],[]]
[[1,[[],9,[7],[7,6]],[3,5,1]]]
[[6],[1,6,[[2,3,2],[7,9,4,3,5],5,[6,6]],[9,5,2,0],[3,[7,1,4,1,2],4,[2,7,7,9],[8,8,4,10]]],[]]
[[[10,7,[],[3,4],[8,1]],[5,[9],3]],[[3,[8,7,0,8,6],[0],[5,3,1,0,5]],[9,[4],10,[8,0,2,10],2]],[[[10,10],0],[]]]
[[2,[[7,5,10,9]],5,5,[]],[[[1,6,5,10,6],[5,8,4,10],[2,5,3,8]]],[[],[[2,10,1],[],8],5],[]]
[[3,[10],9,[5,[],[2,3],6,7]],[[],4,9],[],[[[1,10,4,10]],0,10]]
[[],[10,[2,[0,8],[7,4],6],2,2,[[2,2,7,2,9]]],[0,[]]]
[[[[10]]],[],[],[[[2,2],6,0,[]],[],10,3,[[4,7,1],[6,10],2]]]
[[[4],[],5]]
[[],[[],3,8,8,10],[7]]
[[]]
[[[3,5,1,[0,8,0,7,6]],[2,10,1,[]],[[8,8,3,8,2]],[[10,1],1,[0,2,6],[10]]],[[[1,2],[5,2,6,7,9],10,1],2,5,[]],[[7],[6,9,10],[2,[6,4,10,1]],3,[[10,5,8],9,[2,5,10,2]]],[[5,6,[7,7,8]],[7,[],7],[],[6,10,[7,7,5]]],[]]
[[[5,[5],[],10,[3]]],[],[],[5,3,4,8,[[0,10,7,3],[5,5,6],[10,7,9,2,7],[6]]],[[],[[6,0,5,10]],[[10,1,1,5,7],[8,6],[],[5,5,5],2]]]
[[8,[9,4,[8,0,3],[0,4],2],[[3],1,1,4]],[5,[1,[],6,5,[4,7,0,8]],3,[[3,8,10,0]]],[7,4,[],1,6],[[[7,4,9,10,8],[],10,[7,9],[2,1,3,8]],2],[[[8,5,1,6,6],[3,9,3,1],[2,10,0,3,5]],7]]
[[7],[2,[10,[9],[9,10],[1,5,8,8,3]],[[3,7,0],3,[9,1,0,9,10],8,[5]],[[1,6,10,9]],3],[[9,1],[[10,1,7]],6]]
[[9,[],4,[[],5],5],[8,[5,6,3,[5,8],[4,10,0]],[3,8]],[8,[[0,1],3,0,1],4,[[2,9,3,1]]],[[5,3,5,1,[6,5,6,3,6]]],[1,[[]],[5],[2],7]]
[[10,9,9,2],[[10,6,7,6,[0,1,10,10,0]]],[2,[3,[6,9,5],9,[]]],[8,2,[]]]
[[],[[7,[8,10,7],[7,8,10,6],3,[]]],[],[[[5,5,1,4,2],6],[],0],[2,4]]
[[5,[8,0,[7,10,7],9,[1,6,9,2]],7],[[10,9,[7]],2,[4,[10,7,0,8,6],[],[4,1],5]],[]]
[[6,2],[0,[],6,[[1,10,4,8,8]]]]
[[[5,[]]]]
[[6,[],2],[0],[[],10,[[1,8],4,[9],[5,2,0,6,9]],[]]]
[[10,[[],[5,8,10]],2,[10,1],[]],[[],5,[6],[3,[2,0,4],6,4,3],[7,4,[],1,7]]]
[[[[5,0],[10,10,3],[9,10,10,10,5],5],5,[[0,1,10,9],10,[8,8,6]],5,9]]
[[4,[[]],[]],[],[[10,[7],0,[3,10,1]]],[[6,3],10,10,[2]],[3,4,[3,6,10,0],[[5],8,[3],[6,2,8,2,2]]]]
[[2,[0,[3]]],[9]]
[[[2,5,[9,10,7],[0]],[[4]]],[9,3,[3,10,9],[9,[3,9,10],[6,3,10]]]]
[[],[8],[[[],10,[],8],5,4],[[6,10,[],5],[8]],[[8,[9,10]],[[9,0,3,4,10],[7,9,4],8]]]
[[5,7,5],[1],[1,[],10],[[9],5,10,0,[]]]
[[7,0],[[],9,4]]
[[3,[]],[[]],[[0,[7],[8,2,9,0]],[[3,2],[3],[3,3,3]],[]]]
[[[[],5],7,[[0,0,1]]],[9,[6,[10,8],[6,7],1],0,[6,0],0],[2,5,[9,3,6],[[5],8,2,5]],[[[],4],[]]]
[[9,10,2,[5,[],[3,7,0,8,3]]],[[9],4],[2,[[3],[9,2,0,3,8],[9,4,2,9,10]],[[5],[4,2,0,8],9,[],[1,6,6,7,8]],10,8],[9,2]]
[[0],[10,[[2],3,2,[9]],[0]],[9,[8]],[1,[],[2,2],8],[7,6,[8,[],5,8],[[6]],7]]
[[0],[[5,7,3,8],[[1,5,2,2,5],9,3],[],[],[[0,0,5,6,1],9]],[[9]]]
[[3,[[3,6,8,3],[]],4],[[9]],[1,[0]]]
[[[1,[6,3,1,4,4],[]],10,10],[[[],[4,6,2,8],[7,3,8]],[],[8],[[9],[4],[5,8]]]]
[[8]]
[[],[8,[[0,2,0],[4],2],[8,[]],10,[]],[0],[[7,2,[6,4,10,7,8],[8,2,10],[3,10,9,5]],[],[1],3]]
[[8,3],[[[7,2],[4]],[],[7,10,[7,7,4],[0,5]]],[10,6,8,8,[[10,9],[9,7],[0,10],[10,6,5,6,2]]],[10,7,8,[[7],3,6]]]
[[[10,[7,6,5,8,7],10,4]]]
[[[9,2,7,2],[[8]]]]
[[],[[0,[8,5,1],2],[[5,9,4,1],8,2],[[3,6,1],[5,4,4,7],[6]]],[],[4,8,[[5,9,6,4],9,[10,6],[0,8,9,1,10]],[4],2]]
[[6,2,[[7,10,2,8,5],2]]]
[[3,[],0,[]],[2,8,[[5]],[2,6,[0,7,0,1]]]]
[[2,[[3,4,9,9],[],[6,6,5,3],9],0],[],[9],[[],[8,2,2,[9,6,0,5],[0]],5,6]]
[[[],8,5],[10,[[8],6]]]
[[[8,5],2,5],[],[]]
[[10,10,[0,0,[4,1,10,5,6]],0,[[7,2],5]],[],[[[10,9],[1,2],[8,1]],6,2,10],[[[10,7],8,[1,9,6,6,10],5,5]]]
[[[[10,10,2],[6,6,6]],[5,5,[4,8,10,5,9]],5,[],[[2,6],4,7,[8,5,6],[2,3,9,2,1]]],[[5],7],[1,[2,3,[1,6,8,8,4]],9]]
[[9],[3],[2,[[],7,4,4,[7,2]],[1,[4,5,6,3]],5,[[7],9,9]]]
[[6],[[5,[8,7]],[[4,4,8,2],9]],[1,7,4,[[5],4,[2],10],10],[6,10,10,[]]]
[[10,4,[[5,0],[2,0,2,4,7],[8,3,7,1],8],[],6],[[4,[10,9]],1,10],[[[1,5,6,2,7],3],[[7,0,2,3],1],[[]]],[[5,[2,1,8],[2,3,9]],[[9,1],[3,3,1,2],[10,6,3,5,2]]],[]]
[[[1,6],[6,2,[3,8,10],[],[7]]],[],[8,[9,[9,1,2,4,10]],8,[],0],[]]
[[[[0],[0,10,7,8],10,9],3]]
[[8,1],[[[2,8,1,1],[],0]],[[],10,3,7]]
[[[1]],[[5,[3,3,0,8],[8,8,5,5,8],7,6],[6,[2,10,3,9],[4],[5,6,1,8,7],[0,9]],[[0,2,2],1,1,5,8],10],[2,3,[6,[9,9,8,1],[],2],7,5],[0,0,1,[],[9]]]
[[9,5],[8,[[10]]],[[[7]],8,2],[3,4],[9,[],[[4,4],3,[3],[9],[5]],[2,[7,3],[0,0],[10,8,2]],10]]
[[[[3,1,7,9],2,[0,0,1,4]],8],[[[7,4],9],[7,9,[],2,10],10],[[[0,2,2],4,6,3,6],2,4],[[8,[4,1,9,3],8,7],[[1],[1,0,6],9,9,5],4],[]]
[[7,2,[[6,5],[6,1],[3,5,5,3,3],9],[[0,7,2],[5,0,2,10,4],[8,3],[],10],0],[]]
[[2,9,1,10]]
[[],[9,10],[8,[[10,10,7,0],[10,2,1,9,3],1,[6,8,8]]],[],[[[10,2]],[[6,0,9,6,4],7],7]]
[[5,4,8,4]]
[[],[[6]],[[8,2,0,[]],[],2],[6,1,[10,2,5],[[],[10],[8,0]]],[[6,2],7,[8,[1]],[]]]
[[[5,6,[1,8],10],[9,[2,3,5,6,10],0,[4,3,5]],2],[],[1,9,1,9,[[],[1],4,10,[2,1,9,5,5]]],[3,2,[],6],[[],[],3,6,2]]
[[1,[[3],10,2,6]],[],[[10,7],2,[],[[],5,6,[2,10]]],[[[9,2],9],[[],4,[10,4,3],10,1],[[4,1,10],[0,3],7],[2,5,7,[0,9,8,5]]]]
[[[],8,[],3],[8,[4,[3,0],[6,6],7,[0,3,5,6]],10,[[10,8,1,1,1]],[]],[4],[4,7],[10,[],1,[9,[0,2],4,2,2],[[5],[1,2,3,7],0,7]]]
[[[10,4,[10,2]]],[[[7,5,8],4,[2,1]],4,9]]
[[0],[],[2,[[1,6,3,5,4],7],4,9]]
[[[2,[6,10,2,10],1,8,[]],10,[7,[],2],[[],5,1,[],4],1],[3,[[10,5,7],[1,5,8,3,9],[7,10,0,5,8]],[[0,4,7,2,1],[6,2,1],[3],0]],[0,2,3]]
[[9,10,3],[[3,[2,8,3],6,2,8],[0,[7]],0],[1,8,[[5,2]],[[7,6,6,5]]]]
[[[]],[10,10,9],[[[2],8],10,[]],[[],[7,[7,9,0],[],0],[2]],[[],[[10],[9,9,2,1,4]],7,4]]
[[2,4],[[1,7,3,5],8]]
[[],[5],[5,9],[2,3,[8,3,[0],2,6]]]
[[[[0,3],[9,2,5,9,4],[5,2,9,8],[5],9],[9,7,[2,4,8]],8,3,[[6],[2]]]]
[[7],[[],10,1,[[8,5,8],[8],[5],[1,2],6]],[9,[[2,2],10,[],4],[],[[3],9,[0,10,8,9]],5]]
[[[[]]],[8,6],[[]],[],[[6,2,5]]]
[[[2,10,[7,6,2]],[10,2],0,10],[[0,6],1,5,7],[10,[]]]
[[],[7,1,[]],[9,3,9],[6],[0,4]]
[[],[[[4,1,3],[10,9,8,7,9],7,[1,2],[8,0,2,5]],[6],6],[]]
[[],[[],[8],[[0,4],8,[7,8,3,9,9]],[],[[],[6,6,10],0]],[[1,1,[],[10,2,8,7]],[[9,6],[9,6,2,10],2,10,10]],[[8,[5,5,7]],[3,8],3],[[[6,0,2,2],[],8],[0,[7,5,4],4,[4],[1]],[8,6],5,3]]
[[[10,3],[[1,0,7,3],6,[1,1,2,10],5,[6,7,4]],[],[5]],[],[],[3,4,[[3,7,9,3,0],6,4]],[0,3,0]]
[[],[],[4,[10,7,[2,9,5]],[],[9,1],10]]
[[[],[2,[1,9],[]]],[],[],[],[6,9,[[6,8],5,2,[4,3,4,6,6]],[[5,2,3,8]],[[3,8],4,5,[4,2,4,1]]]]
[[7,[5,[4],4],1,[[2,5,8,2],0,[9,4]],1],[[9,4,8,[0],5]],[],[8,[5,[2,5,8,6,8],3,1]],[]]
[[[0,[9,6,2,7,9]],[8,[1,1,8]],4,[3],8],[[5,[8,6],3,1,5],4,8,[],[[1,1]]]]
[[],[[3,3],[[8,8],10,2],9,4],[0],[3]]
[[3],[],[8],[]]
[[[5,[8,5]],[9,2]],[[[4,9],[3,1],[2,7,5],[2,9,2]],0],[[2,10,2,[],[4,4,4]]],[[7,[1,2,5],[],9],[8,3,[3,8,0,1,10],0,5],1,7],[[[8,0,6,2],[],4,[10]],3,[],4,8]]
[[[[9,8,4,2,4],[0,2,0],5],[7,[4,7,10],[]],[[4,0],2],[8,[2,0,10,4],[7,6]]],[],[1,[[1,4,9,8,6],4]]]
""";
#endregion
}

View File

@@ -1,582 +0,0 @@
using System.Drawing;
using Spectre.Console;
using Color = Spectre.Console.Color;
namespace AdventOfCode.Days;
public enum CellType
{
Air = 0,
Rock,
Sand
}
public class MapPath
{
public IEnumerable<Point> Points => _points;
private readonly IList<Point> _points;
public MapPath()
{
_points = new List<Point>();
}
public MapPath(IEnumerable<Point> points)
{
_points = new List<Point>(points);
}
public void AddPoint(Point point)
{
_points.Add(point);
}
public void DrawPath(CellType[,] map, int xOffset, int yOffset)
{
if (!_points.Any())
{
return;
}
// Draw each point
var previousPoint = _points.First();
foreach (var point in _points.Skip(1))
{
// Draw horizontally
if (previousPoint.X != point.X)
{
var xStart = Math.Min(previousPoint.X, point.X);
var xEnd = Math.Max(previousPoint.X, point.X);
for (int x = xStart; x <= xEnd; x++)
{
map[x + xOffset, point.Y + yOffset] = CellType.Rock;
}
}
// Draw vertically
else
{
var yStart = Math.Min(previousPoint.Y, point.Y);
var yEnd = Math.Max(previousPoint.Y, point.Y);
for (int y = yStart; y <= yEnd; y++)
{
map[point.X + xOffset, y + yOffset] = CellType.Rock;
}
}
// Use current point for next point drawing
previousPoint = point;
}
}
public void DrawPath(IDictionary<Point, CellType> map)
{
if (!_points.Any())
{
return;
}
// Draw each point
var previousPoint = _points.First();
foreach (var point in _points.Skip(1))
{
// Draw horizontally
if (previousPoint.X != point.X)
{
var xStart = Math.Min(previousPoint.X, point.X);
var xEnd = Math.Max(previousPoint.X, point.X);
for (int x = xStart; x <= xEnd; x++)
{
map[point with { X = x }] = CellType.Rock;
}
}
// Draw vertically
else
{
var yStart = Math.Min(previousPoint.Y, point.Y);
var yEnd = Math.Max(previousPoint.Y, point.Y);
for (int y = yStart; y <= yEnd; y++)
{
map[point with { Y = y }] = CellType.Rock;
}
}
// Use current point for next point drawing
previousPoint = point;
}
}
}
public class Day14 : Day
{
public override int Number => 14;
public override string Name => "Regolith Reservoir";
private readonly Point _sandSource = new(500, 0);
private Point _offsetSandSource;
public override void RunPart1(bool display = true)
{
var map = GenerateMap();
// Draw canvas
var canvas = GenerateCanvas(map);
canvas.SetPixel(_offsetSandSource.X, _offsetSandSource.Y, Color.IndianRed1);
// Simulate sand fall
int sandBlocksCount = 0;
while (GenerateSand(map, canvas, _offsetSandSource))
{
sandBlocksCount++;
}
if (display)
{
AnsiConsole.Write(canvas);
AnsiConsole.MarkupLine($"[green]Total sand blocks: [yellow]{sandBlocksCount}[/][/]");
}
}
public override void RunPart2(bool display = true)
{
var map = GenerateDictionaryMap();
// Compute ground level
var yMax = map.Keys.Max(p => p.Y);
var groundLevel = yMax + 2;
// Simulate sand fall
int sandBlocksCount = 0;
while (GenerateSand(map, _sandSource, groundLevel))
{
sandBlocksCount++;
}
if (display)
{
AnsiConsole.Write(GenerateCanvas(map, _sandSource));
AnsiConsole.MarkupLine($"[green]Total sand blocks: [yellow]{sandBlocksCount}[/][/]");
}
}
private static bool GenerateSand(CellType[,] map, Canvas canvas, in Point sandSource)
{
// Stop if source is blocked
if (map[sandSource.X, sandSource.Y] == CellType.Sand)
{
return false;
}
var width = map.GetLength(0);
var height = map.GetLength(1);
var sandPosition = new Point(sandSource.X, sandSource.Y);
// Make sand fall till we don't go outbound
while (sandPosition.X >= 0 && sandPosition.X < width && sandPosition.Y >= 0 && sandPosition.Y < height)
{
// Fall outbound below
if (sandPosition.Y + 1 >= height)
{
return false;
}
// Try below
if (map[sandPosition.X, sandPosition.Y + 1] == CellType.Air)
{
sandPosition.Y += 1;
continue;
}
// Fall outbound on the left
if (sandPosition.X - 1 < 0)
{
return false;
}
// Try on the left
if (map[sandPosition.X - 1, sandPosition.Y + 1] == CellType.Air)
{
sandPosition.X -= 1;
sandPosition.Y += 1;
continue;
}
// Fall outbound on the right
if (sandPosition.X + 1 >= width)
{
return false;
}
// Lastly try on the right
if (map[sandPosition.X + 1, sandPosition.Y + 1] == CellType.Air)
{
sandPosition.X += 1;
sandPosition.Y += 1;
continue;
}
// Can't go anywhere, stop
break;
}
map[sandPosition.X, sandPosition.Y] = CellType.Sand;
canvas.SetPixel(sandPosition.X, sandPosition.Y, Color.SandyBrown);
return true;
}
private static bool GenerateSand(IDictionary<Point, CellType> map, in Point sandSource, int groundY)
{
// Stop if source is blocked
if (map.GetValueOrDefault(sandSource, CellType.Air) == CellType.Sand)
{
return false;
}
var sandPosition = new Point(sandSource.X, sandSource.Y);
// Make sand fall till we don't go outbound
while (true)
{
// Sand is touching ground, stop here
if (sandPosition.Y + 1 >= groundY)
{
break;
}
// Try below
var below = sandPosition with { Y = sandPosition.Y + 1 };
if (map.GetValueOrDefault(below, CellType.Air) == CellType.Air)
{
sandPosition = below;
continue;
}
// Try on the left
var left = new Point(sandPosition.X - 1, sandPosition.Y + 1);
if (map.GetValueOrDefault(left, CellType.Air) == CellType.Air)
{
sandPosition = left;
continue;
}
// Lastly try on the right
var right = new Point(sandPosition.X + 1, sandPosition.Y + 1);
if (map.GetValueOrDefault(right, CellType.Air) == CellType.Air)
{
sandPosition = right;
continue;
}
// Can't go anywhere, stop
break;
}
map[sandPosition] = CellType.Sand;
return true;
}
private static Canvas GenerateCanvas(CellType[,] map)
{
var width = map.GetLength(0);
var height = map.GetLength(1);
var canvas = new Canvas(width, height);
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
canvas.SetPixel(x, y, ColorCellType(map[x, y]));
}
}
return canvas;
}
private static Canvas GenerateCanvas(IDictionary<Point, CellType> map, in Point sandSource)
{
// Compute dimensions
var xMin = map.Keys.Min(p => p.X);
var xMax = map.Keys.Max(p => p.X);
var yMin = map.Keys.Min(p => p.Y);
var yMax = map.Keys.Max(p => p.Y);
var width = xMax - xMin + 1;
var height = yMax - yMin + 1;
var canvas = new Canvas(width, height);
// Fill background
for (int x = xMin; x <= xMax; x++)
{
for (int y = yMin; y <= yMax; y++)
{
canvas.SetPixel(x - xMin, y - yMin, Color.Grey23);
}
}
// Fill canvas
foreach (var (point, cellType) in map)
{
canvas.SetPixel(point.X - xMin, point.Y - yMin, ColorCellType(cellType));
}
canvas.SetPixel(sandSource.X - xMin, sandSource.Y - yMin, Color.IndianRed1);
return canvas;
}
private CellType[,] GenerateMap()
{
var paths = Input.ReadAllLines()
.Select(line => new MapPath(line.Split(" -> ")
.Select(p => p.Split(','))
.Select(s => new Point(int.Parse(s[0]), int.Parse(s[1])))))
.ToList();
// Compute xMin, xMax, yMin, yMax
int xMin = paths.SelectMany(p => p.Points).Min(p => p.X);
int xMax = paths.SelectMany(p => p.Points).Max(p => p.X);
int yMax = paths.SelectMany(p => p.Points).Max(p => p.Y);
// Construct 2D map
var width = xMax - xMin + 1;
var height = yMax + 1;
var map = new CellType[width, height];
// Fill rocks
paths.ForEach(p => p.DrawPath(map, -xMin, 0));
// Compute new sand source
_offsetSandSource = _sandSource;
_offsetSandSource.Offset(-xMin, 0);
return map;
}
private static Color ColorCellType(CellType cellType)
{
return cellType switch
{
CellType.Air => Color.Grey23,
CellType.Rock => Color.LightSlateGrey,
CellType.Sand => Color.SandyBrown,
_ => throw new Exception("Invalid CellType")
};
}
private static IDictionary<Point, CellType> GenerateDictionaryMap()
{
var paths = Input.ReadAllLines()
.Select(line => new MapPath(line.Split(" -> ")
.Select(p => p.Split(','))
.Select(s => new Point(int.Parse(s[0]), int.Parse(s[1])))))
.ToList();
// Construct 2D map
var map = new Dictionary<Point, CellType>();
// Fill rocks
paths.ForEach(p => p.DrawPath(map));
return map;
}
#region Input
public const string Input =
"""
521,171 -> 525,171
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
503,109 -> 507,109
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
503,150 -> 503,154 -> 501,154 -> 501,162 -> 513,162 -> 513,154 -> 507,154 -> 507,150
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
503,150 -> 503,154 -> 501,154 -> 501,162 -> 513,162 -> 513,154 -> 507,154 -> 507,150
481,79 -> 481,81 -> 478,81 -> 478,89 -> 490,89 -> 490,81 -> 485,81 -> 485,79
488,38 -> 493,38
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
482,93 -> 496,93 -> 496,92
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
497,29 -> 502,29
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
501,32 -> 506,32
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
490,16 -> 490,20 -> 484,20 -> 484,26 -> 499,26 -> 499,20 -> 494,20 -> 494,16
503,115 -> 507,115
524,173 -> 528,173
481,79 -> 481,81 -> 478,81 -> 478,89 -> 490,89 -> 490,81 -> 485,81 -> 485,79
486,47 -> 490,47
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
490,16 -> 490,20 -> 484,20 -> 484,26 -> 499,26 -> 499,20 -> 494,20 -> 494,16
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
495,50 -> 499,50
492,41 -> 496,41
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
522,177 -> 522,178 -> 536,178 -> 536,177
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
503,121 -> 507,121
503,150 -> 503,154 -> 501,154 -> 501,162 -> 513,162 -> 513,154 -> 507,154 -> 507,150
515,121 -> 519,121
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
498,35 -> 503,35
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
503,171 -> 507,171
509,121 -> 513,121
494,12 -> 494,13 -> 507,13 -> 507,12
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
500,112 -> 504,112
488,124 -> 488,126 -> 485,126 -> 485,129 -> 496,129 -> 496,126 -> 491,126 -> 491,124
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
488,124 -> 488,126 -> 485,126 -> 485,129 -> 496,129 -> 496,126 -> 491,126 -> 491,124
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
512,173 -> 516,173
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
502,38 -> 507,38
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
503,150 -> 503,154 -> 501,154 -> 501,162 -> 513,162 -> 513,154 -> 507,154 -> 507,150
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
506,169 -> 510,169
490,16 -> 490,20 -> 484,20 -> 484,26 -> 499,26 -> 499,20 -> 494,20 -> 494,16
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
503,150 -> 503,154 -> 501,154 -> 501,162 -> 513,162 -> 513,154 -> 507,154 -> 507,150
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
488,124 -> 488,126 -> 485,126 -> 485,129 -> 496,129 -> 496,126 -> 491,126 -> 491,124
491,121 -> 495,121
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
518,173 -> 522,173
501,50 -> 505,50
497,115 -> 501,115
498,47 -> 502,47
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
518,169 -> 522,169
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
489,44 -> 493,44
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
481,79 -> 481,81 -> 478,81 -> 478,89 -> 490,89 -> 490,81 -> 485,81 -> 485,79
509,167 -> 513,167
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
487,133 -> 487,134 -> 501,134
481,79 -> 481,81 -> 478,81 -> 478,89 -> 490,89 -> 490,81 -> 485,81 -> 485,79
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
512,118 -> 516,118
490,16 -> 490,20 -> 484,20 -> 484,26 -> 499,26 -> 499,20 -> 494,20 -> 494,16
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
512,165 -> 516,165
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
491,35 -> 496,35
500,173 -> 504,173
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
490,16 -> 490,20 -> 484,20 -> 484,26 -> 499,26 -> 499,20 -> 494,20 -> 494,16
503,150 -> 503,154 -> 501,154 -> 501,162 -> 513,162 -> 513,154 -> 507,154 -> 507,150
483,50 -> 487,50
481,79 -> 481,81 -> 478,81 -> 478,89 -> 490,89 -> 490,81 -> 485,81 -> 485,79
500,118 -> 504,118
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
492,47 -> 496,47
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
495,38 -> 500,38
494,12 -> 494,13 -> 507,13 -> 507,12
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
494,118 -> 498,118
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
488,124 -> 488,126 -> 485,126 -> 485,129 -> 496,129 -> 496,126 -> 491,126 -> 491,124
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
488,124 -> 488,126 -> 485,126 -> 485,129 -> 496,129 -> 496,126 -> 491,126 -> 491,124
509,115 -> 513,115
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
506,173 -> 510,173
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
481,79 -> 481,81 -> 478,81 -> 478,89 -> 490,89 -> 490,81 -> 485,81 -> 485,79
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
505,35 -> 510,35
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
506,118 -> 510,118
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
503,150 -> 503,154 -> 501,154 -> 501,162 -> 513,162 -> 513,154 -> 507,154 -> 507,150
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
509,171 -> 513,171
494,12 -> 494,13 -> 507,13 -> 507,12
509,38 -> 514,38
488,124 -> 488,126 -> 485,126 -> 485,129 -> 496,129 -> 496,126 -> 491,126 -> 491,124
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
495,44 -> 499,44
482,93 -> 496,93 -> 496,92
515,171 -> 519,171
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
481,79 -> 481,81 -> 478,81 -> 478,89 -> 490,89 -> 490,81 -> 485,81 -> 485,79
522,177 -> 522,178 -> 536,178 -> 536,177
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
497,147 -> 497,137 -> 497,147 -> 499,147 -> 499,146 -> 499,147 -> 501,147 -> 501,142 -> 501,147 -> 503,147 -> 503,144 -> 503,147 -> 505,147 -> 505,140 -> 505,147
515,167 -> 519,167
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
506,112 -> 510,112
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
522,177 -> 522,178 -> 536,178 -> 536,177
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
488,124 -> 488,126 -> 485,126 -> 485,129 -> 496,129 -> 496,126 -> 491,126 -> 491,124
487,133 -> 487,134 -> 501,134
497,121 -> 501,121
476,63 -> 476,58 -> 476,63 -> 478,63 -> 478,55 -> 478,63 -> 480,63 -> 480,56 -> 480,63 -> 482,63 -> 482,57 -> 482,63 -> 484,63 -> 484,55 -> 484,63 -> 486,63 -> 486,55 -> 486,63
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
489,50 -> 493,50
465,76 -> 465,71 -> 465,76 -> 467,76 -> 467,72 -> 467,76 -> 469,76 -> 469,68 -> 469,76 -> 471,76 -> 471,73 -> 471,76 -> 473,76 -> 473,71 -> 473,76 -> 475,76 -> 475,70 -> 475,76 -> 477,76 -> 477,71 -> 477,76 -> 479,76 -> 479,73 -> 479,76 -> 481,76 -> 481,74 -> 481,76 -> 483,76 -> 483,72 -> 483,76
512,169 -> 516,169
490,16 -> 490,20 -> 484,20 -> 484,26 -> 499,26 -> 499,20 -> 494,20 -> 494,16
494,32 -> 499,32
490,16 -> 490,20 -> 484,20 -> 484,26 -> 499,26 -> 499,20 -> 494,20 -> 494,16
488,106 -> 488,97 -> 488,106 -> 490,106 -> 490,100 -> 490,106 -> 492,106 -> 492,101 -> 492,106 -> 494,106 -> 494,105 -> 494,106 -> 496,106 -> 496,96 -> 496,106 -> 498,106 -> 498,102 -> 498,106 -> 500,106 -> 500,101 -> 500,106 -> 502,106 -> 502,102 -> 502,106 -> 504,106 -> 504,100 -> 504,106
""";
#endregion
}

View File

@@ -1,292 +0,0 @@
using System.Collections.Concurrent;
using System.Drawing;
using Spectre.Console;
namespace AdventOfCode.Days;
public class SensorBeaconPair
{
public Point SensorPosition { get; }
public Point BeaconPosition { get; }
public int SensorRange =>
Math.Abs(SensorPosition.X - BeaconPosition.X) + Math.Abs(SensorPosition.Y - BeaconPosition.Y);
public SensorBeaconPair(in Point sensorPosition, in Point beaconPosition)
{
SensorPosition = sensorPosition;
BeaconPosition = beaconPosition;
}
}
public class CoverRange
{
public int Start { get; }
public int End { get; }
public int Covered => End - Start + 1;
public CoverRange(int start, int end)
{
Start = start;
End = end;
}
public CoverRange(CoverRange coverRange)
{
Start = coverRange.Start;
End = coverRange.End;
}
public CoverRange Subtract(CoverRange other)
{
// Overlap on left
int newStart;
if (other.Start <= Start && other.End >= Start)
{
newStart = other.End + 1;
}
else
{
newStart = Start;
}
// Overlap on right
int newEnd;
if (other.Start <= End && other.End >= End)
{
newEnd = other.Start - 1;
}
else
{
newEnd = End;
}
return new CoverRange(newStart, newEnd);
}
public static CoverRange operator -(CoverRange left, CoverRange right)
{
return left.Subtract(right);
}
}
public class Day15 : Day
{
public override int Number => 15;
public override string Name => "Beacon Exclusion Zone";
public override void RunPart1(bool display = true)
{
const int targetY = 2_000_000;
// Parse pairs
var pairs = ParsePairs();
var ranges = new List<CoverRange>(pairs.Count);
// Get which columns are included on line targetY, remove the ones which already contains a beacon
var beaconsOnTargetY = new HashSet<int>();
foreach (var sensorBeaconPair in pairs)
{
// Get covered columns on y line
var xCenter = sensorBeaconPair.SensorPosition.X;
var coveredColumns = sensorBeaconPair.SensorRange - Math.Abs(sensorBeaconPair.SensorPosition.Y - targetY);
if (coveredColumns > 0)
{
ranges.Add(new CoverRange(xCenter - coveredColumns, xCenter + coveredColumns));
// Check if the beacon is on targetY
if (sensorBeaconPair.BeaconPosition.Y == targetY)
{
beaconsOnTargetY.Add(sensorBeaconPair.BeaconPosition.X);
}
}
}
// Remove overlapped ranges => inner.Start >= outer.Start && inner.End <= outer.End));
ranges.RemoveAll(inner =>
ranges.Where(outer => outer != inner).Any(outer => inner.Start >= outer.Start && inner.End <= outer.End));
// Compute unique number of x columns
long totalCovered = 0;
for (int i = 0; i < ranges.Count; i++)
{
var range = ranges[i];
var coverRange = range;
// Add number of covered columns and then subtract common ones
for (int j = i + 1; j < ranges.Count; j++)
{
var exclude = ranges[j];
coverRange -= exclude;
}
totalCovered += coverRange.Covered;
}
// Remove lines which contains a beacon
totalCovered -= beaconsOnTargetY.Count;
// Print total covered columns on line Y
if (display)
{
AnsiConsole.MarkupLine($"[green]Number of positions that cannot contain a beacon: [yellow]{totalCovered}[/][/]");
}
}
public override void RunPart2(bool display = true)
{
const int xMin = 0;
const int xMax = 4_000_000;
const int yMin = 0;
const int yMax = 4_000_000;
bool IsOutbound(Point point) => point.X is < xMin or > xMax || point.Y is < yMin or > yMax;
// Parse pairs
var pairs = ParsePairs();
// Find all points that are just outside a sensor range
var possiblePoints = new ConcurrentBag<Point>();
Parallel.For(0, pairs.Count, i =>
{
var pair = pairs[i];
var sensor = pair.SensorPosition;
var distance = pair.SensorRange + 1;
for (int x = -distance; x <= distance; x++)
{
var y = distance - Math.Abs(x);
var positivePoint = new Point(sensor.X + x, sensor.Y + y);
var negativePoint = new Point(sensor.X + x, sensor.Y - y);
// If both points are outbound, just skip
var positiveIsOutbound = IsOutbound(positivePoint);
var negativeIsOutbound = IsOutbound(negativePoint);
if (positiveIsOutbound && negativeIsOutbound)
{
continue;
}
// Check if this point is just outside at least one other sensor range
for (int otherIndex = 0; otherIndex < pairs.Count; otherIndex++)
{
if (otherIndex == i)
{
continue;
}
var otherPair = pairs[otherIndex];
var otherSensor = otherPair.SensorPosition;
var otherDistance = otherPair.SensorRange + 1;
if (!positiveIsOutbound)
{
var distancePositive = Math.Abs(positivePoint.X - otherSensor.X) +
Math.Abs(positivePoint.Y - otherSensor.Y);
if (distancePositive == otherDistance)
{
possiblePoints.Add(positivePoint);
}
}
if (!negativeIsOutbound)
{
var distanceNegative = Math.Abs(negativePoint.X - negativePoint.X) +
Math.Abs(negativePoint.Y - negativePoint.Y);
if (distanceNegative == otherDistance)
{
possiblePoints.Add(negativePoint);
}
}
}
}
});
// Keep the only outside detection point
var finalPoint = possiblePoints.First(f =>
pairs.All(p => Math.Abs(f.X - p.SensorPosition.X) + Math.Abs(f.Y - p.SensorPosition.Y) > p.SensorRange));
var tuningFrequency = finalPoint.X * (long) 4_000_000 + finalPoint.Y;
if (display)
{
AnsiConsole.MarkupLine($"[green]Tuning frequency: [yellow]{tuningFrequency}[/][/]");
}
}
private static IList<SensorBeaconPair> ParsePairs()
{
var pairs = new List<SensorBeaconPair>();
foreach (var line in Input.ReadAllLines())
{
var span = line.AsSpan();
// Parse sensor position
int sensorXStart = span.IndexOf('=') + 1;
int sensorXEnd = span.IndexOf(',');
var sensorX = int.Parse(span[sensorXStart..sensorXEnd]);
span = span[sensorXEnd..];
int sensorYStart = span.IndexOf('=') + 1;
int sensorYEnd = span.IndexOf(':');
var sensorY = int.Parse(span[sensorYStart..sensorYEnd]);
span = span[sensorYEnd..];
// Parse beacon
int beaconXStart = span.IndexOf('=') + 1;
int beaconXEnd = span.IndexOf(',');
var beaconX = int.Parse(span[beaconXStart..beaconXEnd]);
span = span[beaconXEnd..];
int beaconYStart = span.IndexOf('=') + 1;
var beaconY = int.Parse(span[beaconYStart..]);
pairs.Add(new SensorBeaconPair(new Point(sensorX, sensorY), new Point(beaconX, beaconY)));
}
return pairs;
}
#region Input
public const string Input =
"""
Sensor at x=1384790, y=3850432: closest beacon is at x=2674241, y=4192888
Sensor at x=2825953, y=288046: closest beacon is at x=2154954, y=-342775
Sensor at x=3553843, y=2822363: closest beacon is at x=3444765, y=2347460
Sensor at x=2495377, y=3130491: closest beacon is at x=2761496, y=2831113
Sensor at x=1329263, y=1778185: closest beacon is at x=2729595, y=2000000
Sensor at x=2882039, y=2206085: closest beacon is at x=2729595, y=2000000
Sensor at x=3903141, y=2510440: closest beacon is at x=4006219, y=3011198
Sensor at x=3403454, y=3996578: closest beacon is at x=3754119, y=4475047
Sensor at x=3630476, y=1048796: closest beacon is at x=3444765, y=2347460
Sensor at x=16252, y=2089672: closest beacon is at x=-276514, y=2995794
Sensor at x=428672, y=1150723: closest beacon is at x=-281319, y=668868
Sensor at x=2939101, y=3624676: closest beacon is at x=2674241, y=4192888
Sensor at x=3166958, y=2890076: closest beacon is at x=2761496, y=2831113
Sensor at x=3758241, y=3546895: closest beacon is at x=4006219, y=3011198
Sensor at x=218942, y=3011070: closest beacon is at x=-276514, y=2995794
Sensor at x=52656, y=3484635: closest beacon is at x=-276514, y=2995794
Sensor at x=2057106, y=405314: closest beacon is at x=2154954, y=-342775
Sensor at x=1966905, y=2495701: closest beacon is at x=2761496, y=2831113
Sensor at x=511976, y=2696731: closest beacon is at x=-276514, y=2995794
Sensor at x=3094465, y=2478570: closest beacon is at x=3444765, y=2347460
Sensor at x=806671, y=228252: closest beacon is at x=-281319, y=668868
Sensor at x=3011731, y=1976307: closest beacon is at x=2729595, y=2000000
""";
#endregion
}

File diff suppressed because it is too large Load Diff

View File

@@ -5,365 +5,116 @@ namespace AdventOfCode.Days;
public class Day3 : Day
{
public override int Number => 3;
public override string Name => "Rucksack Reorganization";
public override string Name => "Lobby";
public override void RunPart1(bool display = true)
{
long sum = 0;
var totalOutputJoltage = 0L;
foreach (var line in Input.ReadAllLines())
Span<int> bank = stackalloc int[100];
foreach (var line in Input.EnumerateLines())
{
var middle = line.Length / 2;
var firstCompartment = line[..middle];
var secondCompartment = line[middle..];
// Parse the line into battery values
for (var i = 0; i < bank.Length; i++)
{
bank[i] = line[i] - '0';
}
var common = firstCompartment.Intersect(secondCompartment).First();
// The first digit the joltage value will be the "left-most" biggest number we can find
var firstDigitMax = bank[0];
var firstDigitMaxIndex = 0;
sum += CharToPriority(common);
for (var i = 1; i < bank.Length - 1; i++)
{
var batteryValue = bank[i];
if (batteryValue > firstDigitMax)
{
firstDigitMax = batteryValue;
firstDigitMaxIndex = i;
// We cannot have a digit bigger than 9
if (batteryValue is 9)
{
break;
}
}
}
// Now we can find the second digit which will be the biggest digit on the right of the first one
var secondDigitMax = bank[firstDigitMaxIndex + 1];
for (var i = firstDigitMaxIndex + 2; i < bank.Length; i++)
{
var batteryValue = bank[i];
if (batteryValue > secondDigitMax)
{
secondDigitMax = batteryValue;
if (batteryValue is 9)
{
break;
}
}
}
// Build the joltage value
totalOutputJoltage += firstDigitMax * 10 + secondDigitMax;
}
if (display)
{
AnsiConsole.MarkupLine($"[green]Sum of priorities is: [yellow]{sum}[/][/]");
AnsiConsole.MarkupLine($"[green]The total output joltage is: [yellow]{totalOutputJoltage}[/][/]");
}
}
public override void RunPart2(bool display = true)
{
long sum = 0;
var totalOutputJoltage = 0L;
foreach (var group in Input.ReadAllLines().Chunk(3))
Span<int> bank = stackalloc int[100];
foreach (var line in Input.EnumerateLines())
{
var firstBag = group[0];
var secondBag = group[1];
var thirdBag = group[2];
// Parse the line into battery values
for (var i = 0; i < bank.Length; i++)
{
bank[i] = line[i] - '0';
}
var common = firstBag.Intersect(secondBag).Intersect(thirdBag).First();
var maxIndex = -1;
for (var digitPosition = 11; digitPosition >= 0; digitPosition--)
{
// Next max is always on the right of previous one
maxIndex++;
sum += CharToPriority(common);
// Find biggest battery value on the right
var max = bank[maxIndex];
for (var i = maxIndex + 1; i < bank.Length - digitPosition; i++)
{
var batteryValue = bank[i];
if (batteryValue > max)
{
maxIndex = i;
max = batteryValue;
// We cannot have a digit bigger than 9
if (batteryValue is 9)
{
break;
}
}
}
// Directly add its value to the total, we don't need to do compound sum
totalOutputJoltage += max * (long) Math.Pow(10, digitPosition);
}
}
if (display)
{
AnsiConsole.MarkupLine($"[green]Sum of priorities is: [yellow]{sum}[/][/]");
AnsiConsole.MarkupLine($"[green]The total output joltage is: [yellow]{totalOutputJoltage}[/][/]");
}
}
private static int CharToPriority(char c)
{
if (char.IsLower(c))
{
return c - 'a' + 1;
}
return c - 'A' + 27;
}
#region Input
public const string Input =
"""
DsPhSBQQQhqmBDhPDsFwjwsLjlRjlttvjvvtRb
rNJMNNbrHrtjHLHjvwtg
fNbNzZdrZnMnMPnQShFPDmnqFm
QWVCFfQffgQCVZzVVpHsHJBqtpspJFRHqq
mwDbmnnGNlNcwNDDNRbnNDlJTpBJBtJGtPTLsBGqTqqsqp
MlSdnScRnnmmDjSdNSdCzvggWzrgzjvfvrgVzW
gsMljbrjlZlWcWMJrWwTwbmwQbmmLDQQLhwL
CdgpzdgpgnfThHfFRwhfRf
SptgpSpnCNpVSGNPvPGSddcMWjMrjqBsJcWqMcBWcVlZ
JcJLQQFWhQJPJpWcwjHvMQvnnlMvzBHd
tCtGZrmVRmVGTVTtCfRTCHHNNvdNzmdMvMlNzvwdvw
CTGGRftfSGtGTGDLbFchSgSWWWcM
QcMFQrvrQbvtczbVbjbMzZzRpqmDDmqqnNzCDCDC
SHHfPJssGLPSdHThLhHdRmqNmNssnNmNCNnpjmsn
LhLJfTdLJwfgPTdfGccrtjcMrccwvcrrFr
jFLLLqDGjbtqLCChpMMhMBvpwMTmffpZ
ZnJHRncHHgnrsrZffTdMdMBfmMvfvR
NWWPnZrVHrZPCDDQtzDCPLCq
jpFjvBZhDFHZdwcmslcslBLLNl
dVtTVVCzzfrrMPNLLcnVcPLRns
CrzWzTqdWtGCzJtbJCrMjjDFHZQjZSpvFGFgHhHp
JjJqMctnhtDZDQtf
TrFFlrrCCHPwHwlPHFPzDhsffQQDsVfWwVJQJB
HHHGdFlHldTpCCFFlLHdCRJccMnqvqMgnNjjMjjvLMLcSv
cMfFcMFcrqgJLFZdrTDdthPGsGmtGs
WwjNwnjjBQzVVQHwRDnmtPGhPPsPnnTGld
bWHBjWVzpbRzbmScqgZMFcqf
RJjPTBJhTNNjfPhRBdqtlgdbGldwtCPgdb
ZmrHHmzpvSvvpzvmvDVCGlWVwCWtGtWCddggqf
QQpzFrHHQnzHvfTcNshcLRNFJhcR
QrPQDrppBQmCmFQm
TzqzsLfmsfSTfqzVLftNdJJNJGCwwGdgCwSGNC
TVHTfzWsfftsZstnbvrbWbrbppPbrmmP
BQrfqrLtJnttqqtQBJDDtBnDzRgldhVVpJlgzpzhpzsgslhV
TTNcPZCvZjmPFZjvPHLlWdNLghVhzzlllpVd
jcFPbTcZTFcmcjMjjFjbLwbnDBtfqbtBwfwSBnrbGw
SZJNJtrNzjjNCzlBBmqmQDBBmDBBjB
PGPbGwhLsnvwnVbGPVMZsDsTBBgcZgBBDBfDBf
pnnhhvphGVpvRPnJlSFRNNJHZHSdSR
hbmDDmwnnVGbhmjNrrWwLNLsWBrw
dMrgvcQqdjlBLlfW
HzzPSrcHqFHQgzpPcMpQqrtmbbbRhHHVGnZDnVHhVbVZ
RwtvdPRvSlTQmHHBQBRL
FjVSjrsFVnFQnTHmnT
VCVVMrWWjVGgbcNVGCCVdlvfdqfvwbSzwqfwZzwv
fmPDwJPDFRmRgPdwwwDNwgwPzhSQzVSzVTQdzHZzHhzQMQzQ
sWtGCWtpcqqpNnQjjzhVTTVQczhj
tWBGntsCNlqrWswDRfFrbFrPDbPf
dmzmjcbQjjQztFNqsqBcMJqNPF
nlTWnClWwQDTVnTrsMsCRBPZRJRJqRJq
wTrhwpVVvgvlDpTvVWVDdLfzgbLtbzSQLSzzjzLz
RWZdHvRdBRGbbvCjJnbn
pqqpSwzpSSbCwPwjlwjl
gDzzqSVzqrThpDBtRtCZdQRQLrQQ
GRqTGqtmTVdGHHVVNNlhPlMqbNqNDbqW
LzQSdFnfznfwBcLcnFppBBDDMPMPhDbhlwbWPlbWMjrD
QznFnLZFvVvHRgsddG
BBHBfBHFdSltmWJvqtNtHq
TQDrrVMzVDnWnNZDJc
gWzprTCrCMQzGGjjhwFwdffjfl
LLLSSSzBBlBLsszncCBZSPSMMMpdWTdrmmnfVGVmMfmrmm
DghttvwhHRvjJthNJwhVtDHGpddMWdMmrMmfGdppjWTfpq
gbJRthQDDRvwtDhQhDFPcVcbPczLzPBScBBF
sZsZpTtLCsbspZtTwrCwrwtDmNNdJmmqSJfqmfNGNmHqGdqb
nQvjTcjQglFVlllMFMVFqWfNqnNHHHdfSfHqfSJq
hFvvgFcFVzphpTrrwZDp
qJqfhsBpfSpchpqcrqwCDvvCDQndmpwDtnRQ
jWHPZWWjZsCmCWRDmQ
PPzMGHlzMNsPLPlZsllgsNrhNVBqhFVBbBSqFFBFrV
RnRsFFdSzmgwvQsqwc
lbgHGMBHlWWWlfWGGBtGwqDpDwmcpMrrqrQDZrMZ
GGJLBVJbVGjGtHVfJtWGHBLLPdzdCghnRnRnSShgNnhnddhj
VgzLFjjwhhSwFhVZgRhRgHHCCvdZdrqqCTvBCrqvvr
ncnNbGMcPpvHFrssdBHM
cnctcNNbQGWFJctftgVmzShzzwwVwgmwfR
pFWmSSFGQlvTbwWTwH
jdBgNhRgMftNBhPbhHnZHlTTZcwZ
lfBNRjCtCfMjsBfCjgfNBRMppGpJqsJQGrrmmJDpGmDDFG
GznngnhzccVdgjbbVjVjVbVLwwQJmQMrLTZhJmZLQTJWmm
pDBSslPCFPCpvCqvpPBQTlQLrdlJWrLJLmrlrr
psSsBptpCBdjtcjNVcGG
sssppsmchwspFLtvHhQJMtFb
rRLDqRVLNSMvFSSV
WDrLnzrDqzRqRzzfLgRnzrnsssZZZsZBgCwwmBppwBspZc
MtPbwvzzVtzfsqGGVpdSjsLd
DnNRCDJBnHJDHDnrDTRcnNZpZSsSLqjpdqqqSMqdddTj
CFRFRFHgDRnRgMtfFvvwzwvwvzWv
PNpFPncvvchPpNjpFhvPhPLmBwMgDRRwRgMDhBmLzBDD
trHSrdTtslWrSWmfzgmMnfBzmn
JsrQsJHHlsVqTjjpbbNnQNNpGG
sVQCdsmGlnlCmnGmQQhGCJJNvNjpgqhqhvPgpgPqjpcpcW
DMSfSbHLHbSDBBzLNvccWRcddvPjNj
FSwHfTFdFsmJlnTTmV
FctwtTTCScvShFqtwScrcTSCJQGNndGHWJNQHWHZdgJrJgGN
jspLlfPlpfsDjBspfllWgdWHQggZHngHNGdsWJ
lRMpBlPmSFRTcvZv
TVZpRRVvFRVpTZRfFhFvvzGVwrwwwdDBMwQrgcDtMtDDwZrL
jsNsWqWjNQCNWbjPMcBLPgBtrdMwdrdL
SJSsmqlSNljbmlNjsbQVffzGRvzmmVhQpVGz
BFFMvcwMwwpFFfpbDMqPVgLVgmLDPR
JtSsSzJssQJJWjRZzgLnDgqLPZgzbg
dsdtWQWdRGjTRNQNQvGfHCCFpvfGwlCfCp
zzWGqWnqnwWCvCrHffHRpBpBBRSJzRFFDhSQFR
VPVsZMNTLsMvPsmBJhllFpFBTJFQpl
sZtsNsZtdZgjbwggjnbvqr
QpTvrphmDvvddfcJJHTTncMlMG
bRZZPRwjgzzlSSjGlnlSJS
BZzBzssWgwzzwNBsgsPBgszmQptqrrGdvdWmqdhhFQDpQF
FfMtzSqlDlzfMhPFhPtffNRsCgSgCCGspRpRGSsgsg
WTcWLTTVnWmrVdLrcHmNGNCZwCCggpgDRwpCnR
JcdWJHTJWdJdjJccrLvlFltFQQvPFDMjqqlP
NfjFNNZPDQVJVWpCbQpJ
lcmdzlmzBtRSTlTTcncsVSbhpLWpWgsWghgsVS
mBTRRmGccRtBwDbrGPbrMMrF
VVQqlsGrVsMWBNFNMQHF
TfzZfDgjgnLGjjztTncCFwwNmdvNcwwNBvHNFwvd
jzjDgZzjntGJZzCnhrrSlPVsJslpslPq
dVhpjGPdjHhqHgtHJJ
sFzrzllQswDwFbcmBlgvZTCgvqTCfgHQJtqT
nDbBsFzzrrtFrlwzPdSVMWMVVMSnGNLd
wqJCjqChmwMLmMmprNgG
DNTtdsdWcHdNspGQggnrgLnQpc
SZvFftdddDsDTtttTDJNCCwJJZzbbCjwwVPj
VstwZCwslBZQDBjfDDBDfS
rvHnmMRrTzmMrmhRppbhDfpjfbjbctjD
rPFLRLmFvvLvHvTCtqsVVwldGZGPGV
SNZDJGfvwgMgfgmLmLcmBqgWgQWr
hPnPTnVGsPRqLWpTmQqQ
tsbnFhhjhSdGJNCjSf
QSbGgBjfTCMWFNPFFtDghPrP
JqHqJVzZzwJJHLlqQptDhPrctpPDtnLF
zZmwJwdwdvHddVJvZqdzHlfGBbsCmMTsWCBCjsGGBbMQ
gVmLtpWrFTFBLtpcFNbvhNNnTnvnQRlQQv
GHjjqsMqwZZJdqGfZjfZGjQDDhvQNzznzRzRwDNbvgzv
sZGPgssMqHZpPptmCcpCrP
CZCNNLmwzwCGMZQMQsFNWplvpsJBWpFHBp
SPbSbDRRbnDqggnbVbVrbRWHJFTlBBcTvWvsPvFpHTcl
tVgSvqVbnqDdgQzMQMGMmzthCw
mpbPQlblbwSlfSPGBpBGPpBFgMMtLFSHMLVVDVdtHLNctF
WnhZsrJhTnWrgZdZgHNLcLtt
hjCsCWRhjzhTjnWnQBbmPQQPLBGfqjwQ
BFrzdtmRmpFtFwwmjjzNQllPshqHvjNh
fWCLLCMJnCDbgfMJhPsPHvqvqVsssQ
WbLnCZnvprpmZrGd
gjMzTGBjWFBCCSSrBC
bddJJndbdJfwPPthrrSSSsFSSg
NJHbZbbvvWGgjWgT
dpfphMggHdQcwftMMgdtzWGfGWnDBnmvnVJVvfmn
CqPFTZPSNCTsZZZRLzGmcGVzDLGvLWBWJm
TCrTNSScPlplpHrQrQ
lqrCvhWFvMGWgfHPgLfjfdgG
zjmbjSnzRzVVRmzBRtwjVQnNLfdPgfLdfTtNLPHTNNpppf
mbSZRzQRBnnzbQJbmjmSbmVhlslZMrclWFrrqWCWsFhchF
mpfNshshflNthWfJCBBdmnQbQBZQdn
VFVRccgGTqTrHTbWBFjJBCFFJCCQ
PvTDHqHqPPGVqqhwfNlWlDhMltlh
HmLLgWVjJwhwWLgjjhmVHLLLlSzBlBlSvBvBFGvtdStJSSvq
TRRrPMsfQTbRRCZRnTMRZZTCcvSccqBqBBlzdFvBqFsGBcts
bRNPbRCZMCrQNfPLdhVpLDVgDhNHWV
sPJFDsSsVLgHjLHPbj
vCnRQhhRQdVQZlZdbHNMlqNNjgjbpbBL
ChhCCCWTWnnmvmGtztStzScwrcVcFW
NRBTNDBglSSgDwCClQQSFFHdLLsFbPFFLt
McpmWccMWHZPcLstbt
MWnWphVMvvzJzpWJWmVphjrDDBBTRwRDDDRRCnPDnqgg
hsnnhhLljLPTmZwvdZdZjmmz
RQNNDpNMSZwvsmqstN
QFMFRDVDsHSpRpHSMRHfGGGTLhCChBGhBhBFBJ
TTbltCvClzvzCZtwtwLTtQQQgjNgmjgQRRRQSjQLjR
HPpnZHcJsdnnfsdVHHSSqghhmqBSSqSmBfNj
VMJJdnMPrMGVrzvCZwZWCzCt
CcQnBBCfBvRzDlsS
PdbPPCbhGGpDSDlDDhvDJl
HmHWPWdbHnCwCHCr
JHlmJcMWHQcPmlmJMmMZPfwTTRDfgdDBfRtgQgdfBw
zVvFrqGjzWGVrqvjvNFpspvVBgNNddtTgghhRTwgdDwwwBfT
bVFrrvsvjWGVsCsqpSHZmMPJlJnCcLcPZZ
QrrQZFZnRtnFRTrnlFTtRZwpGGwzGszhjzbsGzzhmjjhhmhf
SgvpDSJSgPBSDPDNgpggmsMhMmffsMmzfJmzHHMj
WNVcCPgSSDCddSdWCpNBclCQQFRQQlnTLFLRZQnLtt
tgvqWqzvntdlzNzzHrbPrMhHMhhrVrjPmC
FGTGGRGTffcJRpQcJJwmjhPLhjnCQPrLPVQrMr
SppRSDRwFnJJwwswTDdtzBzqWWzZDldNgtvl
sjzPjLphMSrlppSp
fbGqgwTqgVTFFcgGTTGcQvfHQZRlSrSlSmMNMBRNNNrZmm
MVcFGTFtqjsJLjjtCd
jVJqTRHjjtDjZnVJVVjnNdwfCFPZmPgCCgCZGCFFrrFg
LSLBMBWsbBBCgfdrFd
ShbbzdzQRNNNVhDN
JwbSRqmSwRwcpmbSSVfhNBTVGGRnNNzRNh
ZPfQPjZZrffQZszhzTnVGBvntsNz
rLjggjQgQgFdPQjLFQZgwLMbWccLSwWHqHfSqpwc
cBhzNpztzHNrpHSHQrhZjZqdJRRgPqjhjqqP
bQwsMTswwVjdZMVRJM
vGWCTDCTQvvtlvQQ
mHVmTTsmzRmRHffmmfMGBzSPMhSWWdDWDSGB
VNcnNbtqqJbcbvgvWhShDBDPhjgPhSjB
FrrbCnqJcbCJcFFbnqJlppCTfQmfmZQTLVswRLZp
rWWppSStfRBLfHPdHHDzlldZ
QrTnQmmVCqvrvJvzJZPHvzHsDs
qgMMmrTTCcnQQmCNQNQmgTpwRWRtwtpcBWwjSRSSpttW
SzWQwwqVbQzwGSfVwffVwbqhFGFFMgGLGMlNMcnNgcvlMg
ddZHHsrCdBssDsHmChFLNNnMvmNnnnFncL
rpJJdHZJdZHQSRJbSfVhww
jLtFhNwNNvHnjFVvQLQLHhfbGDMPfffpllpttZMPPZZb
VmrqszVmgCWWggbPGclPlZbcZCbf
JdrTmVTVsqsRJHvQnnhwhBLH
vpdBvsvdVvSPhvQFCgrRmhjqqRgWcWWgmf
tJDGbZHbjRHNrrBj
DnMnzGJJwtzVSzzBzTBSTF
hZMDbQhMhlMDJrDrPMJRRqGJSvFvSwFSVdvGvwSFqq
HjjzcRTnpGVSGGFWHH
pssmjctLzpsRRnhlQbPfPrgDbZls
FJMhPhnTMGmBFdnmlrfqfCcwlwCwCv
pjHLsLbjjRHsHsjDjVsgDRjzCnfCfzqrqvwgflcvcvvgqz
njtpHZnLLQGhTtTWSSSh
NMddMTDrrjNnrnMWMrlnPwNwftBtGvptGjBHgBgpfCCSfgvf
mqRqLFZRVFbtgBSCbGWWHp
LZZRmQhVLLFzZdTQPndPNTTnQW
CprQrcpqhHhpppchpphdcdpLMRMGsVGGsMsLbZbtbfMRmtbG
DzlgTjwPTlSSSCDSlggNmMRtbsstsMfbwtVssMmt
TNCNSBNJJTNPJjCTBDzjlJrvvcQrrhphWBqHhHdqrnrr
ScbcbglMPRSmvclTlzMTdhVHhhjfdsdhrVDzfjrD
LJGtpQwpQBBCttJLGqtqGHhPfDdHwjjhrVrhdrdshr
WCpZQCGqtqQWtQWplZPcvMmgmvPccbvT
tGWqthqGVdzBWwdd
BZvZHFFHZrHZvZNRRHHZNHrMMTzRMTdTzbgDVMVssTDTwg
JnNmrHHNrCGBPPnGGc
wvFvZBmppBdSLcvshcLrgl
bTQqJJHJzJjDQjQtzRVJztDHslgNNVLcgSrsSsWrSslWgrgL
TqHHjQnbHTbbmZBBcFMpmBwn
ZFCqSlCPdCRTLWWTQQLLQS
GjggHcvsggHVTVBLnlcpBQ
hvGhlrtjmjrHHhjsMPFNPdtqMPqqRfCf
cgRwVfVzrgqqwZctTztFMFMTCdPmmF
bWJsSJHpTDRDTWMC
sHHNbshnlJhJjBsjsbnBHbZcqrZZQwqvvZcrwwvRcZnr
ttgVBtMbttngmHJVpzlzZlppzw
cPcsRPmPPQfGcccRQSSZzzvzlflzZHvJppzJzT
sQPSCPPWccWWWqsQqRCQFNRMmnbnjjNbgDdBjhBrdbdDbd
gSsZDSgdQZgWSgddwLDLLfCDBqvlhBlClqtqjhvBhB
RMcsVMcsbVsrPrmJcPHHVvfjjCnvvfCqhlqvqqqq
NFMRRpHPgzszGppG
WmmZZNJCgCBZCzPvmBCmjWjjqFtFqjFjbVwqwjtt
ppDMpdMfSfSSNtlwqbqwwq
dTGDhdnfLMLhfDDpQvZNZgmrmrQJgrLQ
jrqRqfNNhrVvcTVdpTscpd
tGWBlLggWGddTspZZd
JJzWtQgQsDbBgDWsgbFrPrRJNMJMPqMNfHjH
GdvVbbWsWdvWGDvWZcbFBTBZCzCjwzrhPBJjzF
nQPfSHnglfpnMSngnMgJTprJCCwwrwCwpTpCFj
SQQHSttRqggmlVsNcvWdRvbWPN
WLNLCWLsSJgHFrSHrM
gDbzRTcmbzPPgPPdtBctfHfrMMQfGFJrhQnMfGJR
dmmzzqZdDqqTLLwjgZgNljws
TCqsDHssmDsDGVGlVcMccGDV
FLntWWnnFzFgzzbtbznLBtlfjGZmcfFGVNFGlVZcMNlN
PpbLLmpgbRzqpCHwChQqwh
lVBPVgflgBVVrVTTwgwBPmgflDQjnnGvqjGDDFjGlGnvqHHJ
ScCLzdCZdbLSbFdFqvDDdGMQGQ
bchNCLRWSbzCbNRzbWRmsrhQwVVwBhmQpPwpgV
GmfHCCPqWqHLWLCfRJpbrrbQphwZbZ
STVDQzNnzMzNdstMDzzNtZwFhrlwVJJrJlFFJRFwFR
DzSvzstnszMnjQcqggjPqQBcqq
BzNwLTqwTjrBrljWpBlrQpBpsCGGCtpssCMttDtHsttMDCHp
mnrJVmRhhvJVcHtsGHMCnZCPZM
bvSmVbRhbgmmSJflzNLrzqzfWfqBWr
qsZLqqFNhfrGnJFv
DVjVmWlcjVjdDTDlbbTDTzmrCnMmJGnHnmCHfJGfvnfM
lVRdDglTlTgVlVjbWWVzVjvNZqSBsLZNtqRsLBqLqQtL
ffRRfLVHZHfJHVJcMrMZZwwTzGBBzBTBjGTwrwdSCj
qmWbWQbqnbvWhbQPGnGNnpvwSzltpBldtSdzllptCSjTTt
vWsbnbWnNvQQQQvsRRLfJRRVGfDcfV
PpqrvswPvvvPsNqmDLDttCCcHHZVrCtW
hgSddBhghQMdbhbwhgSdQgCCctZcDtLntLttCVLtSLCc
dGzdQMFzQMdgGGlGJMzBgBwRqNNfmmTsvfRfJTpwjmpP
pcphpdrWDmTgHWMtRWqHRVVH
SbGcGGQnvNQGvsjBtVHBLjvqVPVB
lzbQCzbZllSzQslpCJpJJDggcggfDT
ffrTlhrVrfCsDVTsWzGBBZcBRBqRBWtGtZcq
QNFmFHrHNSSmSLJdJrNGZLbGjbcBjBGjqcbgjc
ddQvPnHddnQJHSHSFPdnFfDDTfDMMCrwMlPTwDCsrC
NBnrNHQHBscvhfBM
bbGtgWWWqZFmnZGZbmVCdMzvvShfzfGcdcfMSS
WqbjnmbnjWgmFFgtWVbWZwNTNLjNprNwQLDwrTrHQr
lwwlcjlzQRBcBccbdLCVnNVWJJzfLndd
pZDMtZpSDMZpMZMsPtHVNJVfRCRddVndnJLSJd
mDTZvTqtDDHttRPcqhQlwgGlghbqBh
DTspTqssqTbdmCMwVmnmlfCD
PLPWjjrSjvPzqZvjvRqjLtPwnnHCmWVcncMnnwmncHcHll
RFztFjjqjQFQTbdTbQ
hTFSVSdhMMVMFjjgbthcbzczcg
DvwCJVJWWJDRnfmbDmccfmmgfb
QrJvPGWWnpVMqdZsZpqM
gRLcHbgnfpgpJjlqqp
SFwrTHFBqlZtBPZq
HTzDwmSvCvCmsmmvTSwvFwcfRRNRLcQRWNssNNbRWLWL
PpMgDMDnsWSnjBQnrjbn
LFcVVGChCFdhdVFZVpVCdVbvQbRrbvBBbBjQSJZrrJrR
FNwGNCCFHcVTHcFdHHHTDzMzfsgzwpPWMmPflmtt
""";
#endregion
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,596 +0,0 @@
using Spectre.Console;
namespace AdventOfCode.Days;
public class Day5 : Day
{
public override int Number => 5;
public override string Name => "Supply Stacks";
private IDictionary<int, Stack<char>>? _stacks;
public override void RunPart1(bool display = true)
{
_stacks = InitStacks();
foreach (var line in Input.ReadAllLines())
{
var split = line.Split(' ');
var moveCount = int.Parse(split[1]);
var fromStack = _stacks[int.Parse(split[3])];
var toStack = _stacks[int.Parse(split[5])];
for (int i = 0; i < moveCount; i++)
{
toStack.Push(fromStack.Pop());
}
}
if (display)
{
for (int i = 1; i <= 9; i++)
{
AnsiConsole.Markup($"[{(i % 2 == 0 ? "yellow" : "green")}]{_stacks[i].Pop()}[/]");
}
AnsiConsole.WriteLine();
}
}
public override void RunPart2(bool display = true)
{
_stacks = InitStacks();
foreach (var line in Input.ReadAllLines())
{
var split = line.Split(' ');
var moveCount = int.Parse(split[1]);
var fromStack = _stacks[int.Parse(split[3])];
var toStack = _stacks[int.Parse(split[5])];
// Push items in reverse order and remove them from the other stack
var items = fromStack.Take(moveCount).Reverse().ToArray();
foreach (var item in items)
{
toStack.Push(item);
fromStack.Pop();
}
}
if (display)
{
for (int i = 1; i <= 9; i++)
{
AnsiConsole.Markup($"[{(i % 2 == 0 ? "yellow" : "green")}]{_stacks[i].Pop()}[/]");
}
AnsiConsole.WriteLine();
}
}
#region Input
private static IDictionary<int, Stack<char>> InitStacks()
{
var stacks = new Dictionary<int, Stack<char>>
{
[1] = new("SLFZDBRH".Reverse()),
[2] = new("RZMBT".Reverse()),
[3] = new("SNHCLZ".Reverse()),
[4] = new("JFCS".Reverse()),
[5] = new("BZRWHGP".Reverse()),
[6] = new("TMNDGZJV".Reverse()),
[7] = new("QPSFWNLG".Reverse()),
[8] = new("RZM".Reverse()),
[9] = new("TRVGLCM".Reverse())
};
return stacks;
}
public const string Input =
"""
move 6 from 1 to 7
move 2 from 2 to 4
move 2 from 7 to 4
move 6 from 4 to 3
move 1 from 5 to 1
move 3 from 8 to 3
move 15 from 3 to 4
move 6 from 5 to 9
move 14 from 4 to 2
move 3 from 2 to 7
move 1 from 2 to 7
move 9 from 9 to 1
move 3 from 2 to 1
move 7 from 6 to 7
move 1 from 6 to 8
move 2 from 9 to 1
move 9 from 2 to 3
move 8 from 3 to 9
move 1 from 1 to 4
move 1 from 8 to 6
move 1 from 6 to 2
move 5 from 9 to 8
move 2 from 9 to 1
move 1 from 4 to 2
move 17 from 1 to 9
move 1 from 3 to 1
move 3 from 2 to 3
move 2 from 4 to 5
move 12 from 7 to 3
move 16 from 9 to 2
move 5 from 7 to 5
move 2 from 1 to 2
move 1 from 3 to 6
move 1 from 4 to 6
move 1 from 7 to 3
move 1 from 6 to 3
move 7 from 3 to 4
move 5 from 8 to 3
move 1 from 6 to 7
move 7 from 3 to 4
move 6 from 3 to 1
move 2 from 4 to 8
move 1 from 5 to 2
move 10 from 4 to 5
move 3 from 5 to 2
move 2 from 8 to 9
move 5 from 2 to 8
move 1 from 3 to 5
move 2 from 5 to 8
move 12 from 5 to 7
move 1 from 4 to 2
move 5 from 9 to 4
move 1 from 2 to 5
move 6 from 1 to 3
move 6 from 3 to 5
move 10 from 7 to 4
move 2 from 7 to 3
move 4 from 7 to 6
move 1 from 9 to 5
move 12 from 2 to 1
move 1 from 8 to 7
move 3 from 7 to 4
move 4 from 4 to 8
move 7 from 5 to 3
move 1 from 2 to 4
move 10 from 1 to 5
move 2 from 1 to 2
move 4 from 6 to 7
move 8 from 8 to 3
move 5 from 4 to 9
move 12 from 3 to 8
move 4 from 3 to 8
move 2 from 9 to 2
move 3 from 5 to 4
move 1 from 3 to 5
move 1 from 7 to 6
move 14 from 4 to 6
move 6 from 5 to 9
move 8 from 2 to 8
move 3 from 5 to 7
move 21 from 8 to 4
move 16 from 4 to 9
move 8 from 6 to 2
move 4 from 6 to 1
move 1 from 4 to 6
move 2 from 4 to 8
move 3 from 1 to 8
move 2 from 4 to 6
move 1 from 6 to 2
move 3 from 8 to 4
move 2 from 2 to 5
move 2 from 5 to 7
move 1 from 8 to 9
move 1 from 4 to 9
move 1 from 1 to 6
move 3 from 6 to 3
move 3 from 2 to 3
move 1 from 4 to 6
move 3 from 6 to 7
move 10 from 9 to 7
move 1 from 4 to 7
move 6 from 8 to 3
move 1 from 6 to 8
move 2 from 2 to 5
move 1 from 2 to 1
move 1 from 8 to 9
move 1 from 2 to 8
move 1 from 1 to 9
move 7 from 9 to 1
move 1 from 8 to 5
move 7 from 1 to 7
move 3 from 5 to 8
move 3 from 7 to 2
move 1 from 8 to 4
move 1 from 2 to 4
move 2 from 4 to 6
move 5 from 3 to 1
move 9 from 7 to 2
move 6 from 3 to 8
move 8 from 2 to 7
move 2 from 6 to 4
move 2 from 1 to 7
move 2 from 1 to 4
move 24 from 7 to 4
move 4 from 8 to 9
move 2 from 7 to 5
move 1 from 5 to 2
move 1 from 3 to 8
move 4 from 2 to 8
move 13 from 9 to 2
move 2 from 8 to 6
move 3 from 9 to 6
move 26 from 4 to 2
move 1 from 5 to 7
move 2 from 6 to 2
move 2 from 4 to 1
move 7 from 2 to 1
move 15 from 2 to 6
move 8 from 2 to 8
move 4 from 6 to 8
move 9 from 2 to 9
move 13 from 6 to 7
move 6 from 1 to 9
move 2 from 2 to 4
move 4 from 1 to 6
move 3 from 8 to 3
move 1 from 4 to 9
move 2 from 6 to 7
move 1 from 4 to 3
move 3 from 3 to 2
move 14 from 7 to 4
move 5 from 9 to 5
move 9 from 8 to 5
move 7 from 9 to 6
move 2 from 5 to 6
move 2 from 9 to 2
move 10 from 5 to 1
move 1 from 3 to 1
move 2 from 8 to 1
move 1 from 9 to 2
move 1 from 7 to 5
move 4 from 2 to 1
move 1 from 9 to 8
move 3 from 4 to 1
move 1 from 8 to 6
move 12 from 1 to 5
move 1 from 1 to 6
move 1 from 7 to 5
move 4 from 6 to 9
move 2 from 2 to 4
move 1 from 9 to 6
move 1 from 1 to 5
move 2 from 9 to 7
move 10 from 6 to 5
move 1 from 6 to 7
move 20 from 5 to 1
move 1 from 7 to 9
move 2 from 9 to 1
move 3 from 5 to 1
move 2 from 8 to 4
move 2 from 8 to 7
move 1 from 5 to 9
move 1 from 8 to 4
move 22 from 1 to 7
move 5 from 4 to 8
move 1 from 5 to 9
move 19 from 7 to 4
move 2 from 9 to 1
move 1 from 5 to 9
move 10 from 1 to 8
move 1 from 9 to 1
move 1 from 8 to 3
move 8 from 4 to 7
move 1 from 5 to 6
move 3 from 4 to 5
move 1 from 5 to 9
move 11 from 7 to 4
move 4 from 4 to 9
move 1 from 6 to 2
move 1 from 3 to 9
move 5 from 9 to 4
move 5 from 7 to 9
move 23 from 4 to 2
move 17 from 2 to 7
move 2 from 2 to 8
move 4 from 4 to 7
move 1 from 4 to 5
move 2 from 5 to 2
move 5 from 8 to 9
move 5 from 2 to 7
move 9 from 7 to 5
move 11 from 9 to 2
move 1 from 4 to 3
move 5 from 8 to 7
move 3 from 8 to 5
move 2 from 1 to 3
move 2 from 3 to 9
move 1 from 5 to 8
move 5 from 7 to 5
move 15 from 5 to 4
move 2 from 8 to 1
move 2 from 5 to 1
move 4 from 4 to 1
move 1 from 8 to 7
move 8 from 2 to 1
move 4 from 2 to 8
move 2 from 7 to 4
move 5 from 8 to 6
move 5 from 7 to 9
move 4 from 6 to 5
move 7 from 4 to 8
move 1 from 6 to 1
move 1 from 3 to 1
move 2 from 5 to 1
move 7 from 1 to 5
move 5 from 1 to 3
move 4 from 7 to 9
move 4 from 3 to 9
move 2 from 9 to 7
move 6 from 9 to 2
move 1 from 4 to 1
move 1 from 3 to 5
move 1 from 2 to 5
move 5 from 9 to 4
move 4 from 4 to 6
move 1 from 8 to 9
move 8 from 4 to 3
move 7 from 7 to 3
move 5 from 1 to 3
move 11 from 5 to 9
move 1 from 7 to 6
move 2 from 3 to 5
move 1 from 3 to 1
move 3 from 6 to 2
move 2 from 5 to 1
move 2 from 1 to 2
move 3 from 1 to 5
move 5 from 9 to 2
move 2 from 6 to 8
move 2 from 3 to 8
move 4 from 9 to 7
move 3 from 5 to 2
move 2 from 1 to 8
move 1 from 9 to 8
move 1 from 9 to 2
move 4 from 7 to 9
move 11 from 8 to 7
move 1 from 8 to 2
move 6 from 9 to 7
move 3 from 7 to 1
move 13 from 2 to 7
move 24 from 7 to 1
move 2 from 2 to 6
move 1 from 8 to 3
move 1 from 9 to 3
move 5 from 2 to 4
move 1 from 2 to 5
move 1 from 6 to 2
move 1 from 6 to 3
move 1 from 2 to 4
move 3 from 7 to 3
move 2 from 1 to 7
move 2 from 3 to 8
move 2 from 7 to 8
move 9 from 3 to 2
move 3 from 4 to 8
move 1 from 5 to 1
move 9 from 2 to 1
move 3 from 4 to 9
move 1 from 7 to 8
move 6 from 3 to 9
move 2 from 1 to 5
move 15 from 1 to 3
move 13 from 3 to 9
move 11 from 1 to 4
move 5 from 4 to 1
move 6 from 3 to 6
move 4 from 4 to 8
move 6 from 1 to 4
move 1 from 5 to 2
move 1 from 2 to 1
move 3 from 4 to 2
move 2 from 8 to 5
move 2 from 4 to 2
move 9 from 9 to 3
move 9 from 3 to 5
move 2 from 9 to 4
move 5 from 2 to 6
move 1 from 1 to 8
move 1 from 4 to 1
move 10 from 9 to 2
move 9 from 2 to 4
move 10 from 4 to 1
move 3 from 1 to 3
move 4 from 1 to 2
move 5 from 2 to 4
move 2 from 5 to 2
move 4 from 1 to 7
move 10 from 5 to 4
move 2 from 2 to 4
move 1 from 9 to 2
move 2 from 3 to 5
move 1 from 3 to 5
move 3 from 6 to 7
move 8 from 4 to 9
move 6 from 6 to 1
move 4 from 9 to 5
move 2 from 9 to 1
move 1 from 2 to 6
move 6 from 5 to 2
move 3 from 7 to 9
move 4 from 8 to 2
move 1 from 7 to 9
move 1 from 5 to 3
move 2 from 7 to 4
move 1 from 7 to 1
move 14 from 1 to 9
move 1 from 1 to 9
move 1 from 3 to 8
move 3 from 2 to 5
move 2 from 4 to 2
move 6 from 8 to 1
move 1 from 2 to 1
move 5 from 1 to 9
move 1 from 1 to 7
move 2 from 8 to 5
move 1 from 5 to 4
move 1 from 6 to 1
move 8 from 2 to 7
move 2 from 6 to 1
move 9 from 9 to 5
move 11 from 4 to 8
move 4 from 7 to 4
move 6 from 4 to 6
move 1 from 7 to 4
move 6 from 6 to 7
move 1 from 5 to 9
move 6 from 8 to 9
move 8 from 9 to 5
move 1 from 4 to 5
move 15 from 9 to 3
move 3 from 1 to 4
move 6 from 7 to 2
move 3 from 4 to 9
move 2 from 7 to 3
move 1 from 7 to 3
move 1 from 7 to 2
move 2 from 8 to 1
move 3 from 8 to 5
move 2 from 1 to 7
move 8 from 3 to 6
move 3 from 6 to 5
move 1 from 6 to 1
move 10 from 5 to 7
move 6 from 5 to 4
move 4 from 2 to 4
move 6 from 5 to 1
move 6 from 1 to 8
move 2 from 9 to 2
move 2 from 9 to 7
move 6 from 3 to 7
move 1 from 3 to 5
move 1 from 1 to 9
move 2 from 8 to 1
move 2 from 5 to 4
move 3 from 3 to 7
move 10 from 4 to 6
move 1 from 9 to 7
move 12 from 7 to 3
move 12 from 3 to 8
move 2 from 1 to 5
move 1 from 1 to 3
move 13 from 8 to 1
move 7 from 7 to 1
move 13 from 6 to 9
move 1 from 7 to 4
move 6 from 5 to 3
move 3 from 4 to 3
move 6 from 3 to 1
move 10 from 9 to 4
move 2 from 7 to 6
move 8 from 1 to 9
move 3 from 2 to 9
move 1 from 3 to 5
move 1 from 3 to 5
move 1 from 1 to 4
move 6 from 9 to 3
move 2 from 6 to 7
move 4 from 9 to 5
move 4 from 1 to 6
move 1 from 2 to 4
move 6 from 1 to 4
move 3 from 9 to 3
move 3 from 6 to 8
move 3 from 8 to 7
move 5 from 5 to 1
move 1 from 3 to 9
move 1 from 9 to 5
move 1 from 3 to 2
move 2 from 5 to 1
move 1 from 6 to 9
move 1 from 6 to 3
move 2 from 9 to 7
move 2 from 8 to 1
move 1 from 3 to 2
move 1 from 2 to 5
move 1 from 7 to 1
move 7 from 7 to 9
move 12 from 1 to 9
move 1 from 5 to 2
move 1 from 7 to 1
move 13 from 4 to 7
move 1 from 9 to 4
move 5 from 7 to 3
move 4 from 9 to 1
move 8 from 7 to 9
move 3 from 2 to 3
move 4 from 3 to 7
move 5 from 4 to 6
move 3 from 9 to 4
move 10 from 1 to 5
move 3 from 4 to 7
move 16 from 9 to 2
move 3 from 9 to 2
move 6 from 5 to 3
move 4 from 6 to 2
move 1 from 4 to 6
move 2 from 6 to 8
move 1 from 5 to 2
move 1 from 5 to 8
move 7 from 7 to 2
move 16 from 2 to 1
move 1 from 5 to 1
move 10 from 2 to 8
move 14 from 8 to 5
move 2 from 2 to 6
move 1 from 2 to 5
move 2 from 2 to 1
move 8 from 1 to 7
move 4 from 1 to 7
move 2 from 1 to 7
move 5 from 3 to 2
move 1 from 1 to 6
move 2 from 2 to 5
move 4 from 1 to 7
move 1 from 2 to 8
move 1 from 2 to 8
move 3 from 6 to 7
move 10 from 7 to 5
move 1 from 2 to 8
move 27 from 5 to 9
move 1 from 5 to 6
move 1 from 6 to 4
move 1 from 4 to 3
move 3 from 3 to 7
move 4 from 3 to 6
move 2 from 6 to 4
move 3 from 8 to 1
move 2 from 6 to 1
move 12 from 7 to 8
move 2 from 3 to 9
move 1 from 9 to 2
move 1 from 2 to 8
move 2 from 1 to 2
move 6 from 3 to 8
move 1 from 7 to 4
move 15 from 9 to 5
move 7 from 9 to 4
move 1 from 2 to 1
move 16 from 8 to 2
move 8 from 5 to 2
move 24 from 2 to 9
move 3 from 1 to 2
move 24 from 9 to 1
move 5 from 5 to 9
move 3 from 4 to 1
move 1 from 7 to 6
move 1 from 6 to 3
move 1 from 3 to 2
move 3 from 2 to 3
move 1 from 5 to 6
move 1 from 2 to 7
""";
#endregion
}

View File

@@ -1,79 +0,0 @@
using Spectre.Console;
namespace AdventOfCode.Days;
public class Day6 : Day
{
public override int Number => 6;
public override string Name => "Tuning Trouble";
public override void RunPart1(bool display = true)
{
int position = 0;
// Store the last 4 characters in a stream (kind of like a sliding window)
var charStream = new Queue<char>();
charStream.Enqueue(Input[0]);
charStream.Enqueue(Input[1]);
charStream.Enqueue(Input[2]);
for (int i = 3; i < Input.Length; i++)
{
charStream.Enqueue(Input[i]);
// Check if all 4 chars are different
if (charStream.ToHashSet().Count == charStream.Count)
{
position = i + 1;
break;
}
charStream.Dequeue();
}
if (display)
{
AnsiConsole.MarkupLine($"[green]Position of start-of-packet marker is: [yellow]{position}[/][/]");
}
}
public override void RunPart2(bool display = true)
{
const int length = 14;
int position = 0;
// Store the last 14 characters in a stream (kind of like a sliding window)
var charStream = new Queue<char>();
for (int i = 0; i < length - 1; i++)
{
charStream.Enqueue(Input[i]);
}
for (int i = length - 1; i < Input.Length; i++)
{
charStream.Enqueue(Input[i]);
// Check if all 14 chars are different
if (charStream.ToHashSet().Count == charStream.Count)
{
position = i + 1;
break;
}
charStream.Dequeue();
}
if (display)
{
AnsiConsole.MarkupLine($"[green]Position of start-of-message marker is: [yellow]{position}[/][/]");
}
}
#region Input
public const string Input =
"""
rgffbnnqvqhhmtmzzmmpmllcggsdswwvvwzzpptbppgngsnncwcnwcwnwgwrwrrnqnlqlccwggrcgrccjgcgwghgffjgjgrgmmsrrhchfcfdccjwwzdzcdcbcjjtfjjltlvvtstvttszsvsmmfccwcjwwzmzhhjvjpvjpppcwppdtdvtdvtvztzvzffdfqqgbgffrgrpgphhbcctssncsnncfcppvnpvnvfnfvnnfggtpplggwsggldllzvzrznncbbjpplbbrrnsrssmrsrhhmqmnqqhpqqnrqnrrtrnnrwrwhhpjhphlhvvgbgzztqtvvmssdshhqnhnjjvhjhqqbrqrrmrlrdllvrlvlccfvcffhfssgvsswhwqqfwfwhhcffjmmjrrbgrgjgrrvsrvvwmwsmmszzvmzvmmwmtthvvfbfllpjpwpwjpwpnpjpqqwtqtwwqpwqqrsqqcpqqssrgsrrjwwqmwmgwgrggmvmgmfgmffjfhjfjttcztccmtmmccnznhhcgcffmnfmmqjjhwwtccbzbhhwnhnsnmsnmnqqchhhnggbzbjzjzszsfsjfjvffnlffvrvddbhhqccdnnzwnznjnpnmppthhqddjhddqjqlqplqqjpjwppqttswsvwvfwflfplffnbfbwfwhhlhtlhtltzzmlmslmlwwgzwzrrwhhlnnrfnnmpppjpgpbbhpbhppbrppbhhzgzczqcqvqggwppcnnhnznvznzhhcpctptpjtppdhhprhrcrpcprpplrprzrnrfnrnlrlvrrfqqnnsqsqrssnrnvvvghvvbzzqppjsjnnrprwrrmqqtfqfwwrdrsddprddbdzbdbndbdjdljjrtjrrnzrzjrzzpssftfmfbflbbcpcsppwrppntnhthlthtbbsmsbmsmggpssnhnjjtsjjwssdjdwwppcbpcclmccwzzrggmgmnnwjnnqppjttvllmhhvcctptbpbdpdhdqqgggbnnqcchlhssltstllvqlvqvdvjdvvqvsvfvhfhlfftqffztzdttfvvzmvzznvnsnjjvqjvjljplpvvzlzhzghgddbbzbmbnztgthrnpsqhhdvprtpdftmqfvgjzgdvqwmvgwbczvbschqfhdvqcfnmbgmtqmlmsqcbfhshrzzbrtpgnwwtzgnjghzrlwhntprqhvshjcfvlnchccbtnswfnmpccdppqrqrhngvlwrpplbnpgzbzwtzwrsptmsmlndcfmbnqgvnqvzwpvrtfsrwfvfwdvplrfdddwcnwhzchmwfjsfvbtbrjchmgqwfvvmpzhqcbzhrcmjrzmgrtnzrcqdqdqnpwjctlhrjcphbbcvhvqnhtwjrvrbzfzfzzplshvrcchvtgtjcnhlzsttwdhcmdvrdlgsngvtzqsjrcptwwbgvfbsvgnmfhmvgqtfzbhhmdznjlsghhnlwzhvplfvlqzbrsjhdvrshjbnfqgpscbpzmnmmcsdbtwbwmsvfjwdvtctslcqfssrhczdptlrjbfzjctqrcbppcfcbqqzhhftdjchtscwgwcnpvrrjvnnwrqtrqmbgdfcpqhddnvdnmlmqcgsndwbcfvfrzsrflsnqrpmszqrdlshlcsfrmnsqmtrvjwqcllftscwrtmvcjsmrlqvdfjzgfdtswqzldqgjvhczpqrfbclnbwcjprjncvhgfmjhgfgnvfzfnvbbstgsgtspdhtfsncttlwmllbbvqftjtshfjlqtjwlvrbwmzfhdmcbhtqdzqtzmdljqprwhqwcvbtfqbpjwztgqrvlrqdwmqrqzvptsgjdqnqdfwfpjdglwgpdrcfrrzmpjmtbwwrqqcsnmphcqtthlnlzlfftrjmtjwwqrldcfjjclzrsqvltsfchfggcwbzbtpqcjfvgpwnwwqrdbdvjplgsgctdhqvttmtpmmjfcqdslhjgtdppbmzbrfbrrjncfdhlmjgdwjrmbgpcgctghbvphpgfvvfvtplqrhnjjhqntjvbsggvrvjgrwptcgqgrmjtprvhnvjsdsfqrqrrltlhvfsjsqpbwndbsnjzplcfqtfbdqdzdvnljcsmjnrmwwjzqwsjbdlclsmccbqwnlpltqhqhmthhrdjwlqwrbltghsvblqntvjqzpmmpqwrrwvhmtfqzhrmjfglwfpthhgbhdmrtprtqgqbdcfqlbbvmzmchzglmpzdvhpqchhclbcvrcmhtzqfzrplbvmdhghsttzgdjbgmmtvlqjsstgwlwchhwmflwbgljgszghvfdsngbtbcnhzmmdmsjqfbcsmgpjwjqgwqdlrgznnmhphbrzcgnqczpcbljjmhnnrmzlpqbswwcjpjqcrtdmgprpmmbprwlmpzcmwlnbzqjsgftrncvmjmjwvqgszsrmrczhjnwlghgndhbthwlhfbncrwqfgnshrmdfhwmfvllhvbmmllwfbgrnrttpzffzvcfjfbrmdqfcfrdqsltpbbttnqnbncfhwghfbgwrltbhwmmlpczsvvdnwhchgfplnjsttsqvsznwvlwzgfnhfrrgplsfwrwnbfhblwtjpldjmzrglhppgsjsgzssbbgrrbdmpwhgjjmlfnpdbvtntcwrvltgfnrgwttvvjhqljjvvnmztwgzcclgbjnjspzwnpgtgvhhhqbzrnvmdcljcdncvpnpdhrhqwvlhllbsrmjbzlgczwjsrvqrqfqmtjrnpbtdhsrfbhrgtgnrmlgcwcmrvrdfcqbfcqczjchgrjpzqfqqmcpvnvbrssfrfsrjmlngplqqsnclgvpfhjbzdppjftlgbmcgdbrvqrclvtdnzhhcmzlrdrgbrqrlvfcnvznnqwswvhdpbbjmsqzcrmjngzmdftjzsjvgfdtcvdwhnwwjlcgcmflzzpzpgzrvmptbjgrdjbzscrglhcjppdjdshnvvbsnnddtbwsdrpnbnlrtppcrzbbjrfzhbwgmjqtmgjvmrjgfdndlmqvhgwprsjnhcmrnfdfdzggjjzcccnsnwwbjzmsfjjfhclptfcwqjhnphpwzszjmsrtnbqpqsvcfcvrrgclwlbrqngdcdlzrdfpvbgtznjzdvjngrgswhjnrpgswtqflpgvnpbsvcrtgtzcbhdjpbjwnpdzcmprtzlppbqvpzrrlbssmwhhvqqpmwggnzwcfdnzccjrrncnvjqgbpstctwpqvhdsbcsjrpbzbdlwwvjngtbnvpthppglgsnrbwnvpzldhsgwqhclgwrdsvcfdclvdsbrhcfnbgrtqswstnjfmfrdgphpvgjfqzcwnpcghdhtflgdnhhnnnwrpnmppszgqdcqjqpnccfsqjsmwtqvzwfqvtwtthwswmcqqcqjwcgwgzgmnpzbfpzrqbvqhbhtsvvbppbmqzfnsmwppzvsctgcncztsqdfhnlwjjtvwcchvnphwpnpzqsjhlrcmnbthtqlfclnsfdtpwfzljdpfszvhgzdpzhbjtphbfbmwgfrfplntfqhgpbjzghmblzzhdcbptngqwrtfmvtbhphpvdwpswbscrwzhnvqfwlbwwqqgstgmbqlllspbhbpjmmrfhmjwzdnsdwmpvlrspgzmdjwqwcjpbgwspsghjdvrbbsbtgwptqdvvdhbhqbdhpbzdsdwsjdbjnztdqqrdhwhtpvcbblbmjgmbpqghdsfthzjffrdvldfsnpcsmnzwzcqlnvcrcbqnfcdrfbffrvhqsbqjnnbzsqvqqdqwmsvbqvtgmnnlthpngfsljqnrdhhzpmwsnqvrgdnvlbgnndfcpjfgmzqssvnnrwbmslcqpnhnnwzggsjvqcsqpfzjcmcppntmsdtfggzdncqbfjsqvbzgnnlsdbgjqffsmvnbqlsrjwdmcjbrsrpchnnhdtlcdhfdltmlvtrwjpzphtbhzzrlrwbbhhpntgbcfmphnbrjdhrhvmvhfglrncngjdsvbfrqtqzsgvlzjqzcqnwdcfgvnpsqpphwfsdvpgnchjnnjhsqgvlqcvhzzzcrsqcvrbsbjbdbgddlbb
""";
#endregion
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,314 +0,0 @@
using Spectre.Console;
namespace AdventOfCode.Days;
public class Day8 : Day
{
public override int Number => 8;
public override string Name => "Treetop Tree House";
public override void RunPart1(bool display = true)
{
var grid = CreateGrid();
var valid = new HashSet<(int, int)>();
// Check each line from left to right
for (int i = 0; i < grid.GetLength(0); i++)
{
int previousTreeSize = -1;
for (int j = 0; j < grid.GetLength(1); j++)
{
var size = grid[i, j];
// The tree on the left is blocking the view, stop searching on this line
if (size <= previousTreeSize)
{
continue;
}
valid.Add((i, j));
previousTreeSize = size;
}
}
// Check each line from right to left
for (int i = 0; i < grid.GetLength(0); i++)
{
int previousTreeSize = -1;
for (int j = grid.GetLength(1) - 1; j >= 0; j--)
{
var size = grid[i, j];
// The tree on the left is blocking the view, don't take it
if (size <= previousTreeSize)
{
continue;
}
valid.Add((i, j));
previousTreeSize = size;
}
}
// Check each column from top to bottom
for (int j = 0; j < grid.GetLength(1); j++)
{
int previousTreeSize = -1;
for (int i = 0; i < grid.GetLength(0); i++)
{
var size = grid[i, j];
// The tree on the top is blocking the view, stop searching on this column
if (size <= previousTreeSize)
{
continue;
}
valid.Add((i, j));
previousTreeSize = size;
}
}
// Check each column from bottom to top
for (int j = 0; j < grid.GetLength(1); j++)
{
int previousTreeSize = -1;
for (int i = grid.GetLength(0) - 1; i >= 0; i--)
{
var size = grid[i, j];
// The tree on bottom is blocking the view, stop searching on this column
if (size <= previousTreeSize)
{
continue;
}
valid.Add((i, j));
previousTreeSize = size;
}
}
if (display)
{
AnsiConsole.MarkupLine($"[green]Total viewable trees: [yellow]{valid.Count}[/][/]");
}
}
public override void RunPart2(bool display = true)
{
var grid = CreateGrid();
var maxScenicScore = 0;
// Compute scenic score for each tree
for (int i = 0; i < grid.GetLength(0); i++)
{
for (int j = 0; j < grid.GetLength(1); j++)
{
var size = grid[i, j];
var score = ComputeScenicScore(grid, i, j, size);
if (score > maxScenicScore)
{
maxScenicScore = score;
}
}
}
if (display)
{
AnsiConsole.MarkupLine($"[green]Max scenic score: [yellow]{maxScenicScore}[/][/]");
}
}
private int ComputeScenicScore(int[,] grid, int i, int j, int size)
{
var visibleTreeCountLeft = 0;
var visibleTreeCountRight = 0;
var visibleTreeCountTop = 0;
var visibleTreeCountBottom = 0;
// Look on left
for (int x = j - 1; x >= 0; x--)
{
visibleTreeCountLeft++;
var nextTreeSize = grid[i, x];
// Blocking the view
if (nextTreeSize >= size)
{
break;
}
}
// Look on right
for (int x = j + 1; x < grid.GetLength(1); x++)
{
visibleTreeCountRight++;
var nextTreeSize = grid[i, x];
// Blocking the view
if (nextTreeSize >= size)
{
break;
}
}
// Look on top
for (int y = i - 1; y >= 0; y--)
{
visibleTreeCountTop++;
var nextTreeSize = grid[y, j];
// Blocking the view
if (nextTreeSize >= size)
{
break;
}
}
// Look on bottom
for (int y = i + 1; y < grid.GetLength(0); y++)
{
visibleTreeCountBottom++;
var nextTreeSize = grid[y, j];
// Blocking the view
if (nextTreeSize >= size)
{
break;
}
}
return visibleTreeCountLeft * visibleTreeCountRight * visibleTreeCountTop * visibleTreeCountBottom;
}
private int[,] CreateGrid()
{
var lines = Input.Split('\n').Select(s => s.Trim()).ToArray();
var grid = new int[lines.Length, lines[0].Length];
for (int i = 0; i < grid.GetLength(0); i++)
{
for (int j = 0; j < grid.GetLength(1); j++)
{
grid[i, j] = int.Parse(lines[i][j].ToString());
}
}
return grid;
}
#region Input
public const string Input =
"""
220102001303332210111144403232401113333122342344231242454143210203320302212443030013122003001101100
002012111323310331302003042221132010432132445255133124455255223004414440440003301012203200022100210
200201202011003110423331304200331011531224544245554512113213335525210302033141324322321031312102110
100020212221032131124244103404003222433224521422334123232422124515312313433224100204010121132311000
200113321032110240111004030043155443522233113242534443312241445211112450323031312112213000023232100
000123222130133422212242344055134444215311551422533215421415442551425225432130430124043210211111310
220013001310041302023441034332322423241253523413533421512551432233114553552003013120121302130121320
103122021001324130041021443134551553414353255343356623553131221454542451225451442032131420112320101
012123121220242033212021343121244143344324534625253522262464534215422121222134240012234133102111220
330310331223230000003152443554413335326665536266322522652335566553114314142351411020403401413302112
033203120011110011132251145135331144533354253453463224233644324632453434135523253300131220303213123
320111230330142103134512313345346434643654336344264466663434525446644113511452351451422214014013322
001132233321313303345535112443242622242446334234425332545346556362543355243332135453212444110331303
112033313244310423153325243233225655536462366623456645652435535435325433454445524512423111021132122
313313043314211444453212142362452645555543222645663664243443432442223333565131234141351344321344102
131230133213133211232332525334634543566623665537334334547734623265434432455254451425235432443212211
033344041000113254352455455346236225633465644343664557364344535543336532242444234311533433344140212
213210413044552341333323656654354424366446744766744473434577534775255332236334522521333331002022121
223112203001555435245233523555243667443447767433564533557556755677732432236462355155425414244240300
031112340101154335334634566542526467535374465476634474475365364377737233444423444335143215320411041
010203132113252122424352345322745777347553756767766736766655557657446763326426264545545441510322304
321034434351253424555342636457546533636345766763737363536656637564757633453436366225532223151301123
140333103113245552456543556436376775537436555564765867677377566536736367466446544545111231522432042
344202325543255413523362252766476773354345756567775846446585764655346457333656245566142114252141442
300442033331415536626644654454735373634646576484854768867856765345656633644236246242335514321313432
422444251112412665556253554536437336675554766648744646768865576456545754676632532244262315154431312
202304543452455552253665657746647784558765457564785778845788767784833536336745445354462312521531440
443202253112536253525354345435633886668445868754667447674764886554756567546737654246334325241222041
444423415155442365223265743454556684558776766888858567565767784775755635475565754224462452335222241
344303321125225553466564654375755674684544768955877976656855558645744675543644552655335222244234041
300235531322254555657355344757787845684787759755989576658884775746464854347454745445252251123331200
202355355135453623555734775437867546864765789685787875887555685885564677653753475626332543431524440
123112125155234436477477667347767767746589595765887578895688659457644647637353775542533353231324344
410231223354354564265577744565557576558859695696978987776856795557766747576576743622336235154122541
144345221145432366464547578854445477995896778965569886979678656986544557875776343376245336222211154
041355524153432432536456778856655655586558689789676558987567866689878584574356765462664355555422315
043213424536224446535754387584686658555998969679778967988975666897764557557733673744622262412325233
101514245332544663477377677875765977975768579996797978899567698975768865784644537776543454651544223
055515332353232236436447686544477656596959996666689896787797795969665874555543664764442344265232243
222545542226664544634434558757485778565956766669899769668998978795896868888674777634532432531545351
434314333334362377634654477865886799965779778887799678789966958767788684856666356767346645644343444
052335546342344533746576644847456965678786776877897777697767787998596844688878543443425354265524523
245321436235332754756734464668569895557967788998689969678678888859577664555777765333674636253522234
222511135542326767344777655475586999669889777967697967976779776769789666884457455657536456246131555
254433214252433545454764655656756765598866789679798998989699886966798756574757563674433652342254411
252443455634345774563668584548569877777679776897897977978768868758769758655687433345452443435424512
312151563634655557774676587765775678576967989777779888989698876657887877756744456665655635556644123
255315424526333665355778666668586665799969869877998777889777988668875966868565465457776522236513141
141324353246555364776377784867669969887687879788978777778977696768597689744655653757436644265454325
354554356562633675467576477485995977969979699799889979879876989688558895876557644555777244452335314
235324556262356365436555887646778779897999678779989989789867689977685966845857674434347554655643252
413432246554227346473675665849975567696667989798798778788967877675576875667875866434546262246521543
552324452542255347547654567456656665796776679978889979999797899897878689747764654756336634422352455
132142446224635664776385465487598668797987978789877989998967699965559668558447437465553652345225512
535121326642222474774354544766768756799778998798789898877898889965958696446887843476762526426515244
345151122435326774546477755588766796667978679897798799788798667756596585444845757774352236466242124
324135422245435777577646446776855665599676997689997887788889876766665986567668467764463526524522524
325343515546653536653454765454579566578777977788879878787979966579696677474785343347473444324354355
411221244324436736446567757755797766577698989699898679769679676797557885877546755664674522365314215
011225512566433343766434774658485575577887896689896789789788897667989867646846655537445534555245154
353122224246523453336574684477667558859686788676888887889677967668868867745484457553323245424151214
025211533334552466553436874465855779555988968677869768998666855765958765844553645533522566662215435
011144555564545656657564766665457958988879979779789696768889888785895588848586367454333255641115431
312135513646235366335766645784546897755855986679986669787888667577687576776674647476324553225412153
401131435555652456777737485558685475567889776796686996966887777867565457675674635564364663332115334
111542111546535443776533554556858445867565786988765999858788986988467667765674337645225253433114412
324152522543244453747533764587454556659676798855686758699569787576577568846344576564242526335344431
123513525116652325364735577676854466795879775965858579978758766786788576585574533555234644544424444
201422231514666656435556464744556487779676697575668797755696587875664885475643663462362633532152224
443133412441244332664735557756557478667877999697777576977768645754645558333564346654626425334525344
431015242443666335263335435575686474856864565688697865686896558787678553436564534565256645251434512
010022255222133364253766673665475577467776484765858776654564844676776444447654375652434614143215022
112002141144134663334274465647734767886457477454887888474577867446657475453544742245245225443332224
331232153352336525225567445365565486747774487468877475878758554778586376763333443326544225345123013
320123541455416433363426343365775545857885758565575848877877686547673556675754423464442514232324111
042432343324232554524246554574474345666464658776446546567878767443577744556362465553665411142432422
142111123322431534522545253754364545474457775847846786887674646573467346333352524442333115335223141
344133332441235422454233333556736343777476764657687856476465776533456554442553426542432524345343333
200031013552112555654336435633347655674473538755855765665344475745556736546535462654344221551230302
304022204315531423544354645467655764773637456746376536645753764476654735362436623665431353330033320
001214000225135351445433524663673656735567443667544556374445736766637732424362445435124235202421144
133240444115255522316642262344554645657446334644647444534543345455733253453543223511253231133210321
324313341004114352115254632235242543363566666546735757746734646346355536356645334223223155213043334
322012103401425423541123244634634342577565467364645454366476547536536356344363313411143511003322321
030233343013121433455142565364335554237444577544465747334546363663525346435245514412331312412441220
210201421410133422542335534522343332455655473755663556635632662655563553445642432325453033042340112
012224401212432145413124536446542562653225343456763356434464356455233544345355532151231212104022112
312232323430402414252325451525553345425256326265324326656464322435443535213233315511433100124021321
010230232102113031224241215434543254266544664634225463436365465636465234441113521431122331212121101
212212302203143433332245352152333246623456656325435343642442543354454522241344343333411433411331230
011102200023414304323524211214225553365332454633645434256444354263245252314454334421304444012133303
120113010124021413002342554241434235565233233626345455655236425423152444344321441224210011210001020
101033322321412021400115241224135351431466535533654236552223322311141154321444212340220200110122301
011220031300131001424314223221135334414132553352224226351421342145342332444324224232200001102210233
121312303322224212003013214154522352135431322413434142221234334123523122531033230010321012211132201
012020110022314203102101331443513341244141113213442111455332441213534235144341443443042312110221221
100013222332201123334301101412554224524144445454322353452424512151232340130231214403422202221333120
211200011012011223124042241233103554151124335225451435512351451314113131210120200021021301331230211
222211000301233212310103403144201411351211113145331241322345244155131304344032001313100223022021012
""";
#endregion
}

File diff suppressed because it is too large Load Diff

4768
Inputs/Day1.txt Normal file

File diff suppressed because it is too large Load Diff

1
Inputs/Day2.txt Normal file
View File

@@ -0,0 +1 @@
6161588270-6161664791,128091420-128157776,306-494,510-1079,10977-20613,64552-123011,33-46,28076-52796,371150-418737,691122-766624,115-221,7426210-7504719,819350-954677,7713444-7877541,63622006-63661895,1370-1981,538116-596342,5371-8580,8850407-8965070,156363-325896,47-86,452615-473272,2012-4265,73181182-73335464,1102265-1119187,3343315615-3343342551,8388258268-8388317065,632952-689504,3-22,988344-1007943

200
Inputs/Day3.txt Normal file
View File

@@ -0,0 +1,200 @@
2232212212212222211221231124224222213132222133122224222123222112324122222122221322222225222342243112
2222312114222314322223142323251122424322142244122212213222222222242526225232262212234353242222112242
3325444446453345434534234244443254434533443354443344424431124344542134454433534353443542455544444483
2334235313232232645234524223233333333323323333233334323332325633143222333322242333132233233132212325
2234311224123424222222224432222333212224412234223312244413252153222112433222334322772215422121224273
4522445145543645454343253542221455532354534564325445322522535254222337733425252243221532745237255133
2214225223121214462323123283942523226421423233325342644222213411423272383842222442422213122912324522
2122242232325524322242212232524425223232232233432221122322233512432222441122422314222122221222212225
8222353391373332335354222456125222358233122233316323355352531234333527222223352436381343533536331244
2127632636444323427265228625582625772229446462233352433587748742382622354425852874557228522772714265
5764566853423796763449339447557566366572334553648326634466376656683936736543746865667784426952852681
2121232232222322211232122232213212117222223222221652221222212242222222222333321322222222222122522223
3311487326434675433324437437335526732665253343574234535363333477334461753847265314545424442324747728
6252536321432743472244167342323675732726575412571775613245775732227775657226312524123527567671676189
7533722333717216436553422342221352632923463174227273634221314835124324462631282462922324654573644336
3334347211322211322233222241233221232124212322322224423224253425525344442212222284312232222324322414
8767635775767537537775596426945666564695551577422716939227657554649562833366674365266155727577774737
7775767466374676353856676436275545371656656638858776373448786645468766554726777677755355577244574383
4124457552243552342355664445373255223422339335535644524442445657442153557545543453354343433643267753
6124333457242323425527522653254242224232423232264274434422411227635523364224422236253335315116127532
3843363244543644643446444336332633352434545244436626634545444448444432343456656564456736353434435763
2422221722221518823422211232528222221322741422521112323225722252542221222152231123242126243222522576
1622233224223242225223226253345331335142347122554523313243535325924223222222332241922222221423233121
4422161223245313242212152356523252352332114532131212331132322223662325121132255222245126112324622222
4233231332312314222233333341133332452443423443134344332243234243444423443533423343333244354382332434
6412258431772524433228362126666441227873942928375972932224772779977239924896932962725678357742792757
2227271234224232322222332222221223242222336232222321222123332221232363322222123232311223225321123324
7589939488935898867996484599788786867736849995938599889798476788896676459989897766888896597487889955
3454654452545325445345241613354242541353364444436354434433222254535434343434244433352454491236544424
3555422223544453332243232524152235232432234321322225424353448233244453333633454744244242322633235544
2124222224441239425244322954112523572245362622825554225282222736532822246252222222625122321847223735
3236336542322621344455252325253252236337264153213264532252332554223524342132622262555624217132225523
2526592122123332422822131141234342452222223213126221224262242336444543224251621223527425633635432422
4627434275335624743842223367643372773416353388754337724725344333445735354575952356357743428124523423
5131323342333323332333223333231343333533322133333351233343323326353222332223323323355332223125436611
3267823353225414622752883222125222822288682231242712212212222312622262222232262239152212766233622742
3233632122333233633333333331713131221283512363322533235333333353253232423232232312332336353232511333
7537335633333332333257451533743636333336344234383233638333825643833324862326234334536343333337341534
7374226635593315434733244453342226646737436272495334563847314623624832636243233334512322529283445263
4332232521223522524213221234143433214242236352238234234145322342235343223263631624558153124433322263
2522212625442322522232213336422222244225234213335226232232544223291312422512225122122152452522284222
3223121222448242222232124324212222232372344252326235832228322247122222322232422122282212222221222334
3532267229665572922222236676865635148363573285411561725352232854345323542463955323228643283411566268
3357562156445382573453552434624343344555753334452344275353435433233343545435554553531442333343545323
4432285342325163234221332435222123365325322323334325472242261325439248524244352229353255664624222332
5431252222458374243642592224346445254352332235374424452555534438625129442442434335415312335582323233
4323424443537342215451244432322222322262445334343422342225131243343242422312542126413331246233333414
4364214533233224324343345333333332333523353333324214315243433333323413413343433343343135333312343333
3223134252331264234231223413332384833323311111472333258232326331233453222123283532162132322222213123
2122322222222332222212412222421222212222335322222123213121232223222355331222241212232223222122212222
2224234336222923229631122212222612332523531322272232233123322223442324123313256323423442722216232512
3333324326462443643324233235432334632354333323332336163232334253342523333223351246225324332353535564
2652435323434322222223325242213225213233122223236242225241342232234132526222345232157223522552124332
3411222222226222221122322113222221223126312216224221122212222122242222222312122212727221212242231221
4456532435443334732561536454334463553353556454575452634335511435653443333455255235435445465545553134
2228332566243332533533252323335332231316214213243333232133434226343943323352214232213322333433335212
3365426738758286223813946783465373375236837736556379353363573387385397747575645375432373453243373298
2374464353232333237353476246233321127232426742236472547323234324246433373336253442412444322493272472
3433823214282232422432246132534272631326662712841823232362422314263262437186423322512121721222764782
2212221325332253132322215232314222142112221124222235222233333213232243132233223322232175233332233222
1322232332221132111122231322312233222432221422243222233423433133225222224321322322323233327224222232
1646353222222366621126365622131123313224423236214524422434321352522352211643433222432424454255232342
3361246654224456345614565445236613412443442534524666655261365666531522166125553226265651516625126789
4324334643744332474343444449444636345744136484654443344354443433464531343444454463434747785437245447
5452122332323323125222212232221332222222222222222231232312182222123242331122112231122421221323232422
2211251211252222622253221332252222212922232222322322221222422124228552222312622122221221222212274322
6312233221334343211331335223232235222532314222232223323423323343132222221133225123323476243233223114
6365746667644366678673776345675677645664653459445634735635562465556549961355736666746565734664645547
3221223222222332212221322122324222122122122211112214222322122122222121222222112112232222231433222122
1422361231254154455327225426522633323223321223545452553224325226628412212635854242361124447216543452
3666233524341323332235392765343263455725455245627253316134426537127422852162423422242634754221114822
3932433363332433232333726333333322334331332636223844223125733237523322343253323322253713213222333332
4493744344343834344443452343336344428436454332433425458644535434483442554494443454624254346454444533
5699934925565955456654646643377577254475687546547848667996565655157229655448156642565884755556349397
2412344544333346124443433363233223333343333344336734136233423334433433343143232333143233365933334343
1629643246222715451822963326475635412213424375224242216415646222713289214241172435222575212224121736
2252522432412549512366312275222222373242325416522265412221721226556221122252235273275426642122427522
1413222233624135145593211616522426244254844452521552272422254536455622433271358325522434313343224463
3224423212432442132244433242415322342232432332224213224242231424233421323324222242444232222443422223
3422233231433314333231233333233333333423333433332331343321233243133333323331342324322433343233423333
4245333537332234633432342332323328332232224343333343334353514454433722242233353641212333285343631332
5223226432542535334272221623443313523443252332624714433827453354551322323276223543323322425214216561
9797352317238959996855458878658559627886527272323796576749782735857222478979158267967842734532637298
2233315472222233225323231342221225322534411322222222252221323222211243442321411412233132323235245223
3242242512222224434221246355113123221214231222336222222262323212273222434232324213712221324222532544
5232232112233212221222742221224212221222222132222221222213222521351152131361223222222221231121122122
2322322121321222222221241222222222222221211222223124142212222222123212322212222122222421122222252222
4334454542453614443324434444464344564545444424444454554444454443434343364344354444434442344253434444
2212322523313311222122522623343141322313342331212442222412224524322223244452231316412252262323322222
2222212272212222122122222522113122242221222222222212222224122222221222122221224121212222212212412221
2262337146893946174873662226535147545374544263382266265526568543452839587616544643126292665282936624
3632252333332333333443223232262335313333233332314333343233345243313243233365363313235323332251334333
3221232222222231322523223221226228231232223121521222423642122221212222322222122223241211231231323322
2221222222211221222321222222321111241222212221223224222111226222222222127221122321122322222222223222
6124144523332424733744135412344413421242123443515845332333352381548533242422427444334537433335322574
7453758454284755866546827436558875877536562985475866626748436685734445624337877296528474836188782753
5725733623574543384332644163741436413538624353353125322413732535252354534676342533233443636764346533
3724543433444425433433334324347463344832345544343464234456334442253444343934444232343544352344734343
6573566365455442255555524262564564545162457584866572865548453564655536755528442528355355335274452555
3222221223313472322312322223112362322312222112321321222323333422212221332242211232332234312422322226
6684364344445364343623423527355342443365534744737476345423442431424363432387333644234536114334313743
3233322323622333233224331231516231133322322232233222222232342523213345323243332215613222522443353132
5233232142321234421331321222222312221211123133132324142229222222223223232222223422232222224362224341
1623812226295322222452341223423224244822222244262222226522254322222354323823234622623342833422134243
8333332232332233233122333321222322323322223212332226112423223216223222223321223122433232322322133323
1445455125545213412322444525223256423451342852266534614222242224134464414322623543351274434232725426
5573546354364544548532342646434444554247464434444334464533335544555447424544744345433465422444335345
4562565676457555226566266835565649635546563647665517725942797526353315545955559436375764268749645898
6575389545666586355556557655258454466366756659655667656556582566555465559455532256575635466765755551
2522372325223285372377443342324824613332232726232122334317271432643232352312841322424762333233395233
2325212222222422242642232311222421214211222221222214422221222242131222122222521362214232321222124221
3443334344363536646652475343315326533663446343345554247337628331336572334445334673738533443665543342
2132212222231122223244212212222212228222233272341222122222242352251212322325222212211922122624222222
9575468865546956387974456933636335313545532835783785683744589494443434344565445464834553577825488995
2232221523232232222252336212562321222122411723311522222422216223221222621222176222222111614122221252
2411324543243436234332382332234214435321523422313323444432433242322423134133444241124142332331234444
3433433334352343225433321342331324334324436434454253433254434433232322423433335424444433233323343334
3223422232335211433544355441333533324324224521343345431633342323623234437234243141342447733332355443
2411332212121252533343422283442212322133324233124822321255297222331282432222722222422225234551324542
1212122312232223236244132211522422335231321321233311413522332233123232243232312123322221522432333223
7334732333343334432153322533242333342334333433542333323344232343333631333134333324341334323332233321
4223522232212222331134221222522114354221215211122143472242233151322215324333435221222111222125242222
3222333222332132352223221213322232222113211132322232323223262222322232231433522222332222122315322222
4241254433142142123222423422312231234332242212342422234142423232314242344322144224343422223212435253
4435124394543415434351654321444434453344533554424428337244554533353443435545332645235353543553624434
4953545494325476235384273555532639985727583622585542734352939855234464949436494654347624427975335752
1232253544413221381621112135437813322644122432322123133243121211252322135345213422232223825116322142
7176762571577351467326138773541464454587645184235842236622256247346688118431458431258687874365414659
2234232222222322322227532122582522122332422321222223222212152215325222223321221223223281421221322272
2425383136529333525526333212772263633723248433642255323553412633172463436577851421236523265744234522
3424262253652335642215242324645354215251762247525283223142532441334534261222436332322215452368293294
3525625641636442423534235631325866434443266454611324526226469346631344363145685421462455233735624345
5276763684237376172166382633667247437378333539246423364394367744953897395676234326742766684349243562
4233422424444222242434315214323442396243233222224442344444422342234344623323212323224426342442427234
2455654832635651757551426372442144653642514347558494583127222312332291665422754344255247559626765126
2423243424113222233244222221234543212222174224434222112321343222222321212333423144422255222222413122
3323333236543227312763323323522323831924221328237333782233235623233343431243535322223335382353122133
2642453233833326882633337743646383422483273534435314347233322527835732448264631373443364128368335834
6321247133126761767527423261476422264542629276752248335262214216629211627473621659671535368222612669
5343777868459585575482665644767666773655757774767864755776477544456869665597555737746565466765544456
1561262334141223245665535412224136232446722652331362425423161246335221246455132554556132262625222555
5725416122222431321214232245422252241221232124234422112421223522241233231222223232253322412111224464
1342634245353479774636277557464349166649866286327455463463636677272756383566156564766367664434525544
2222214123614223121322332318514242112223523113141382142232142142233231421222362222233262322213343743
6232323432322254643333225193233343333423321243245225332132242323632264522322336122232231212351212223
3134444244333433225323244553224323233233323334332322233334131123434334332263343643354324333333333333
5532268321431422223343232322352234537313226334376242424454322432374463252213326577332252837226334641
5454844649566486677668957445459426468556946465673647773845366434343566647393767866654877854729566655
2422261322545145375223322644442555224434132222357432123332514282554322645316424122242235533345325354
3453712694444284286643414431362435383471343775542345353323626357143668234121858535252933816335326432
2692252814322492259236385535955522425425223342262252322174535732822419432644742213257343242222582643
6224333313434321343237423443742234422322332352563424433343233254324214252234443222233353343243333445
4341454432233455223475433475834433424452531334443432434434543434324144237344441424343324333441646255
7434464744476424675745843545587323486545535756479535344455254523223337565676533355416635334549535976
3553356443855549413244624436535286254385433334226234338534135565231251535244343542565554226235635334
6573451149567373447735352333764555854832677437453435454465844374557267983453554498384334844362354649
3222254452422632224342325232542722451421242426521244243425424432222231324222222222222224444132543462
2122421222232412322232411222341132211222815512622251621622322425233342126123321222212233532357222222
2212232521412331133232455327233262332232323333233232141422322434333231222732323462221323232213222211
3232332221511232236313222373234232352363332233522423133221423342323322222133322133333332222243322362
2336422223291359222423422723843312323142222422352222453222313423325226423333532343317321422225321142
4343335344372513234535342343343331535336323543354634443324332253537437441345145433453334416434323352
3237453244334333332544534453434432432453435333343236534453223333433262234443423444431235133845232333
6456227863763242255472623627231646622542245446515545363156162236672662444622442685215534225266296642
2221332422312223552533253124222143223432222123213232331623267323322312232362544423433242224434255212
6223465529466236233843281262333513534533347144636335524465365425322223373826446133535333335936553663
2422522232222332132222436342244222212125223234334411321232322424384243222245362244243432424231222224
2455326555464433825522411753425666565575612655266536636523455355543744564462384354365164425355735543
2222222223222222111222222222212213221233232222222332113222221222262222132221221212122223112222122132
3757772733244484433471354299755673837533632373346333735764325326263332933364634336225349447642767347
6437333932233533335653243853723337632339355633363334344352325433234631533434522225121233842335623366
1522322353333243423526152523222341222216322522631222136252125432232222422232211222322636312253262237
3244925232233442334453242444241423433222233234323483133314262243244121333332323242321254222333333331
2353223342323312327232322421224232123221132271242314335221333242245322142323223222134422332222223313
2232223222152322222221221121232212124133322431112342321232222222321222211232233311232221222232222123
3453545474334436473443566463435375435867524354646246572375445332562455654454447265633425553447415546
8325538754433525383334434495321546255334334349823332443333244294334243537453573399238389554251532513
7656246667563266466285456546456634856666957366663567458366756667648824545698465586644656686567376793
4215351543432113323415311324225123133123142113334411255112542454441323515215512232515424352535536789
1111223223122222222212222222222121222121222222225422222222212322222222233211242234122121222221222213
5678874659337973585843437281459576744742867132948467828423979842756986437335768649266634535646384756
3321432323333214232334221532121112433224263223323333735223333142518214311333551312233337431332222331
3221122322355421122222453222425223221222442312325124432242254223232322354422311511222231212225272322
3326243721153143233313222221442134142337593334337525233226413533524382451233373863723253915332223322
4323922223241324233114233242234372243132523323224232522234672222932332123232522413335233242223326132
4322523121353121333322532434134233233114242224344533323351233542365523264233431435614923234534264343
2413439321538222312223262451523242222223422221322414424312213143162222233225243213124234222242234342
3342122215245575225214522336225122222452225452142422442322242424233553522122474675551126222332423412
2233212232112143223212212231131212212233232223222231322122222122333332123123222222332132432232232322
3123343334341232234231322243134412132113314413424131312441443333224114142441423243344314242144456789
5385554234435342844722553342162686427245123565484553455665282646565214247314425653986444256446243726
1423322322142322343222211212322232222242323233132433232122324221321213111311232212131253212246222322
2251232221222126122123211222231232221222262212221122111222221232222322212212212223221222222222222242
4433211425222435344223312275476734164333243421521257332731712552245523223432413345313534272123232531
5374861454518743534536288564523325333536745576255527655233661778769564756756829149877383953443336824
3313122322343331253323335333343224231126233223221243331333312332333332332332233322123323223253233333
4413524351244212524255443427242452242444414252125243353241535255256425423353123331432285522243215864
4233233624553534233334344223842653442554363333343434314464443234333354472933333443314632434634254324
3553898859594653737688866779538897656477718999867897996545698835748668695853929454638293454775739576
3616433333424364342231322772322273742562435322524343222733733633315231217432253332344435423437477333

View File

@@ -25,6 +25,19 @@ var selectedDay = AnsiConsole.Prompt(select);
var stopWatch = new Stopwatch();
// Read input
try
{
selectedDay.ReadInput();
}
catch (Exception e)
{
AnsiConsole.WriteException(e);
Environment.Exit(1);
}
// Part 1
AnsiConsole.MarkupLine($"[cyan]Running [yellow]{selectedDay}[/]...[/]\n");
AnsiConsole.MarkupLine("[cyan]Part [yellow]1[/] result:[/]");
@@ -44,7 +57,9 @@ catch (Exception e)
stopWatch.Reset();
// Part 2
AnsiConsole.MarkupLine("\n[cyan]Part [yellow]2[/] result:[/]");
try
{
stopWatch.Start();

View File

@@ -14,4 +14,25 @@ public static class StringExtensions
{
return new StringReader(text).ReadAllLines();
}
public static char[,] AsCharGrid(this string text)
{
var lines = text.ReadAllLines().ToArray();
var lineCount = lines.Length;
var columnCount = lines[0].Length;
var grid = new char[lineCount, columnCount];
for (int i = 0; i < lineCount; i++)
{
var line = lines[i];
for (int j = 0; j < columnCount; j++)
{
grid[i, j] = line[j];
}
}
return grid;
}
}