35 Commits
2k22 ... master

Author SHA1 Message Date
ded4631c3b [2k25] Add day 8 2025-12-13 17:55:37 +01:00
6cf07be0c6 [2k25] Add day 7 2025-12-07 20:04:48 +01:00
e7afab8c99 [2k25] Add day 6 2025-12-07 15:32:02 +01:00
f100c7596b [2k25] Add day 5 2025-12-06 23:15:01 +01:00
04102d1fec [2k25] Add day 4 2025-12-04 21:35:12 +01:00
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
28 changed files with 8527 additions and 12918 deletions

View File

@@ -2,14 +2,24 @@
<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>
<ItemGroup>
<Content Include="Inputs\Day8.txt" />
</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 Day6();
[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

@@ -5,592 +5,129 @@ 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 string Name => "Cafeteria";
public override void RunPart1(bool display = true)
{
_stacks = InitStacks();
var freshIngredients = 0;
var idRanges = new List<IdRange>();
foreach (var line in Input.ReadAllLines())
var readingRanges = true;
foreach (var line in Input.EnumerateLines())
{
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++)
// Read ranges
if (readingRanges)
{
toStack.Push(fromStack.Pop());
// End of ranges
if (line.IsWhiteSpace())
{
readingRanges = false;
continue;
}
var rangeSeparatorIndex = line.IndexOf('-');
var lower = long.Parse(line[..rangeSeparatorIndex]);
var upper = long.Parse(line[(rangeSeparatorIndex + 1)..]);
idRanges.Add(new IdRange(lower, upper));
}
else
{
// Read ingredients
var ingredientId = long.Parse(line);
if (idRanges.Any(range => ingredientId >= range.Lower && ingredientId <= range.Upper))
{
freshIngredients++;
}
}
}
if (display)
{
for (int i = 1; i <= 9; i++)
{
AnsiConsole.Markup($"[{(i % 2 == 0 ? "yellow" : "green")}]{_stacks[i].Pop()}[/]");
}
AnsiConsole.WriteLine();
AnsiConsole.MarkupLine($"[green]Fresh ingredients count: [yellow]{freshIngredients}[/][/]");
}
}
public override void RunPart2(bool display = true)
{
_stacks = InitStacks();
var idRanges = new List<IdRange>();
var rangesToDelete = new List<IdRange>();
foreach (var line in Input.ReadAllLines())
// Read ranges
foreach (var line in Input.EnumerateLines())
{
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)
// End of ranges
if (line.IsWhiteSpace())
{
toStack.Push(item);
fromStack.Pop();
break;
}
var rangeSeparatorIndex = line.IndexOf('-');
var lower = long.Parse(line[..rangeSeparatorIndex]);
var upper = long.Parse(line[(rangeSeparatorIndex + 1)..]);
// Simplify ranges if there is overlap
rangesToDelete.Clear();
var skipRange = false;
foreach (var idRange in idRanges)
{
// Distinct
if (lower > idRange.Upper || upper < idRange.Lower)
{
continue;
}
// Outer overlap
if (lower >= idRange.Lower && upper <= idRange.Upper)
{
skipRange = true;
break;
}
// Inner overlap
if (lower <= idRange.Lower && upper >= idRange.Upper)
{
rangesToDelete.Add(idRange);
}
// Left overlap
if (lower >= idRange.Lower && lower <= idRange.Upper)
{
lower = idRange.Lower;
rangesToDelete.Add(idRange);
}
// Right overlap
if (upper >= idRange.Lower && upper <= idRange.Upper)
{
upper = idRange.Upper;
rangesToDelete.Add(idRange);
}
}
if (!skipRange)
{
foreach (var idRange in rangesToDelete)
{
idRanges.Remove(idRange);
}
idRanges.Add(new IdRange(lower, upper));
}
}
var freshIngredients = idRanges.Sum(range => (range.Upper - range.Lower) + 1);
if (display)
{
for (int i = 1; i <= 9; i++)
{
AnsiConsole.Markup($"[{(i % 2 == 0 ? "yellow" : "green")}]{_stacks[i].Pop()}[/]");
}
AnsiConsole.WriteLine();
AnsiConsole.MarkupLine($"[green]Fresh ingredients count: [yellow]{freshIngredients}[/][/]");
}
}
#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
private record struct IdRange(long Lower, long Upper);
}

View File

@@ -1,3 +1,5 @@
using System.Buffers;
using System.Numerics;
using Spectre.Console;
namespace AdventOfCode.Days;
@@ -5,75 +7,203 @@ namespace AdventOfCode.Days;
public class Day6 : Day
{
public override int Number => 6;
public override string Name => "Tuning Trouble";
public override string Name => "Trash Compactor";
private static SearchValues<char> DigitsSearchValue = SearchValues.Create(
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
);
public override void RunPart1(bool display = true)
{
int position = 0;
long grandTotal = 0;
var numberRows = new List<List<long>>(4);
var symbolRow = new List<char>();
// 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++)
var rowIndex = 0;
foreach (var line in Input.EnumerateLines())
{
charStream.Enqueue(Input[i]);
// Check if all 4 chars are different
if (charStream.ToHashSet().Count == charStream.Count)
if (rowIndex <= 3)
{
position = i + 1;
break;
numberRows.Add([]);
}
charStream.Dequeue();
foreach (var range in line.Split(' '))
{
var span = line[range];
// Ignore split columns
if (span.IsWhiteSpace())
{
continue;
}
// Numbers
if (rowIndex <= 3)
{
numberRows[rowIndex].Add(int.Parse(span));
}
// Symbols
else
{
symbolRow.Add(span.Trim()[0]);
}
}
rowIndex++;
}
// Do the calculations
var count = numberRows[0].Count;
for (var i = 0; i < count; i++)
{
checked
{
grandTotal += symbolRow[i] switch
{
'+' => numberRows[0][i] + numberRows[1][i] + numberRows[2][i] + numberRows[3][i],
'*' => numberRows[0][i] * numberRows[1][i] * numberRows[2][i] * numberRows[3][i],
_ => throw new ArgumentOutOfRangeException()
};
}
}
if (display)
{
AnsiConsole.MarkupLine($"[green]Position of start-of-packet marker is: [yellow]{position}[/][/]");
AnsiConsole.MarkupLine($"[green]The grand total is: [yellow]{grandTotal}[/][/]");
}
}
public override void RunPart2(bool display = true)
{
const int length = 14;
int position = 0;
long grandTotal = 0L;
var numberRows = new List<List<long>>(4);
var symbolRow = new List<char>();
// 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++)
var lines = Input.Split(Environment.NewLine);
for (var i = 0; i < 4; i++)
{
charStream.Enqueue(Input[i]);
numberRows.Add([]);
}
for (int i = length - 1; i < Input.Length; i++)
var offset = 0;
while (offset < lines[0].Length)
{
charStream.Enqueue(Input[i]);
// Check if all 14 chars are different
if (charStream.ToHashSet().Count == charStream.Count)
// Find offset at which the next set of numbers stop
var numbersEnd = offset + 1;
var foundSpaceColumn = false;
while (!foundSpaceColumn)
{
position = i + 1;
break;
foreach (var line in lines)
{
// If any line does not contain a space, we can go next offset
if (line[numbersEnd] is not ' ')
{
numbersEnd++;
foundSpaceColumn = false;
break;
}
foundSpaceColumn = true;
}
}
charStream.Dequeue();
for (var i = 0; i < numberRows.Count; i++)
{
var span = lines[i].AsSpan()[offset..numbersEnd];
// Parse number with correct offset
var lastPaddingIndex = span.LastIndexOfAnyExcept(DigitsSearchValue);
var lastDigitIndex = span.LastIndexOfAny(DigitsSearchValue);
if (lastPaddingIndex > lastDigitIndex)
{
numberRows[i].Add(long.Parse(span) * (int)Math.Pow(10, lastPaddingIndex - lastDigitIndex));
}
else
{
numberRows[i].Add(long.Parse(span));
}
}
// Also get the symbol
symbolRow.Add(lines[4][offset]);
// Next pack of numbers starts after the space column
offset = numbersEnd + 1;
}
// Do the calculations
Span<long> numbersBuffer = stackalloc long[4];
var count = numberRows[0].Count;
for (var i = 0; i < count; i++)
{
numbersBuffer[0] = numberRows[0][i];
numbersBuffer[1] = numberRows[1][i];
numbersBuffer[2] = numberRows[2][i];
numbersBuffer[3] = numberRows[3][i];
NumbersToRtl(numbersBuffer);
grandTotal += symbolRow[i] switch
{
'+' => numbersBuffer[0] + numbersBuffer[1] + numbersBuffer[2] + numbersBuffer[3],
'*' => ValueOrIdentity(numbersBuffer[0]) * ValueOrIdentity(numbersBuffer[1]) * ValueOrIdentity(numbersBuffer[2]) * ValueOrIdentity(numbersBuffer[3]),
_ => throw new ArgumentOutOfRangeException()
};
}
if (display)
{
AnsiConsole.MarkupLine($"[green]Position of start-of-message marker is: [yellow]{position}[/][/]");
AnsiConsole.MarkupLine($"[green]The grand total is: [yellow]{grandTotal}[/][/]");
}
return;
void NumbersToRtl(Span<long> numbers)
{
Span<char> number0 = stackalloc char[4];
Span<char> number1 = stackalloc char[4];
Span<char> number2 = stackalloc char[4];
Span<char> number3 = stackalloc char[4];
numbers[0].TryFormat(number0, out _, "D4");
numbers[1].TryFormat(number1, out _, "D4");
numbers[2].TryFormat(number2, out _, "D4");
numbers[3].TryFormat(number3, out _, "D4");
// Reconstruct numbers
for (var i = 0; i < 4; i++)
{
var number = 0;
if (number0[i] - '0' is not 0 and var digit0)
{
number = digit0;
}
if (number1[i] - '0' is not 0 and var digit1)
{
number = (number * 10) + digit1;
}
if (number2[i] - '0' is not 0 and var digit2)
{
number = (number * 10) + digit2;
}
if (number3[i] - '0' is not 0 and var digit3)
{
number = (number * 10) + digit3;
}
numbers[i] = number;
}
}
long ValueOrIdentity(long value) => value is 0
? 1
: value;
}
#region Input
public const string Input =
"""
rgffbnnqvqhhmtmzzmmpmllcggsdswwvvwzzpptbppgngsnncwcnwcwnwgwrwrrnqnlqlccwggrcgrccjgcgwghgffjgjgrgmmsrrhchfcfdccjwwzdzcdcbcjjtfjjltlvvtstvttszsvsmmfccwcjwwzmzhhjvjpvjpppcwppdtdvtdvtvztzvzffdfqqgbgffrgrpgphhbcctssncsnncfcppvnpvnvfnfvnnfggtpplggwsggldllzvzrznncbbjpplbbrrnsrssmrsrhhmqmnqqhpqqnrqnrrtrnnrwrwhhpjhphlhvvgbgzztqtvvmssdshhqnhnjjvhjhqqbrqrrmrlrdllvrlvlccfvcffhfssgvsswhwqqfwfwhhcffjmmjrrbgrgjgrrvsrvvwmwsmmszzvmzvmmwmtthvvfbfllpjpwpwjpwpnpjpqqwtqtwwqpwqqrsqqcpqqssrgsrrjwwqmwmgwgrggmvmgmfgmffjfhjfjttcztccmtmmccnznhhcgcffmnfmmqjjhwwtccbzbhhwnhnsnmsnmnqqchhhnggbzbjzjzszsfsjfjvffnlffvrvddbhhqccdnnzwnznjnpnmppthhqddjhddqjqlqplqqjpjwppqttswsvwvfwflfplffnbfbwfwhhlhtlhtltzzmlmslmlwwgzwzrrwhhlnnrfnnmpppjpgpbbhpbhppbrppbhhzgzczqcqvqggwppcnnhnznvznzhhcpctptpjtppdhhprhrcrpcprpplrprzrnrfnrnlrlvrrfqqnnsqsqrssnrnvvvghvvbzzqppjsjnnrprwrrmqqtfqfwwrdrsddprddbdzbdbndbdjdljjrtjrrnzrzjrzzpssftfmfbflbbcpcsppwrppntnhthlthtbbsmsbmsmggpssnhnjjtsjjwssdjdwwppcbpcclmccwzzrggmgmnnwjnnqppjttvllmhhvcctptbpbdpdhdqqgggbnnqcchlhssltstllvqlvqvdvjdvvqvsvfvhfhlfftqffztzdttfvvzmvzznvnsnjjvqjvjljplpvvzlzhzghgddbbzbmbnztgthrnpsqhhdvprtpdftmqfvgjzgdvqwmvgwbczvbschqfhdvqcfnmbgmtqmlmsqcbfhshrzzbrtpgnwwtzgnjghzrlwhntprqhvshjcfvlnchccbtnswfnmpccdppqrqrhngvlwrpplbnpgzbzwtzwrsptmsmlndcfmbnqgvnqvzwpvrtfsrwfvfwdvplrfdddwcnwhzchmwfjsfvbtbrjchmgqwfvvmpzhqcbzhrcmjrzmgrtnzrcqdqdqnpwjctlhrjcphbbcvhvqnhtwjrvrbzfzfzzplshvrcchvtgtjcnhlzsttwdhcmdvrdlgsngvtzqsjrcptwwbgvfbsvgnmfhmvgqtfzbhhmdznjlsghhnlwzhvplfvlqzbrsjhdvrshjbnfqgpscbpzmnmmcsdbtwbwmsvfjwdvtctslcqfssrhczdptlrjbfzjctqrcbppcfcbqqzhhftdjchtscwgwcnpvrrjvnnwrqtrqmbgdfcpqhddnvdnmlmqcgsndwbcfvfrzsrflsnqrpmszqrdlshlcsfrmnsqmtrvjwqcllftscwrtmvcjsmrlqvdfjzgfdtswqzldqgjvhczpqrfbclnbwcjprjncvhgfmjhgfgnvfzfnvbbstgsgtspdhtfsncttlwmllbbvqftjtshfjlqtjwlvrbwmzfhdmcbhtqdzqtzmdljqprwhqwcvbtfqbpjwztgqrvlrqdwmqrqzvptsgjdqnqdfwfpjdglwgpdrcfrrzmpjmtbwwrqqcsnmphcqtthlnlzlfftrjmtjwwqrldcfjjclzrsqvltsfchfggcwbzbtpqcjfvgpwnwwqrdbdvjplgsgctdhqvttmtpmmjfcqdslhjgtdppbmzbrfbrrjncfdhlmjgdwjrmbgpcgctghbvphpgfvvfvtplqrhnjjhqntjvbsggvrvjgrwptcgqgrmjtprvhnvjsdsfqrqrrltlhvfsjsqpbwndbsnjzplcfqtfbdqdzdvnljcsmjnrmwwjzqwsjbdlclsmccbqwnlpltqhqhmthhrdjwlqwrbltghsvblqntvjqzpmmpqwrrwvhmtfqzhrmjfglwfpthhgbhdmrtprtqgqbdcfqlbbvmzmchzglmpzdvhpqchhclbcvrcmhtzqfzrplbvmdhghsttzgdjbgmmtvlqjsstgwlwchhwmflwbgljgszghvfdsngbtbcnhzmmdmsjqfbcsmgpjwjqgwqdlrgznnmhphbrzcgnqczpcbljjmhnnrmzlpqbswwcjpjqcrtdmgprpmmbprwlmpzcmwlnbzqjsgftrncvmjmjwvqgszsrmrczhjnwlghgndhbthwlhfbncrwqfgnshrmdfhwmfvllhvbmmllwfbgrnrttpzffzvcfjfbrmdqfcfrdqsltpbbttnqnbncfhwghfbgwrltbhwmmlpczsvvdnwhchgfplnjsttsqvsznwvlwzgfnhfrrgplsfwrwnbfhblwtjpldjmzrglhppgsjsgzssbbgrrbdmpwhgjjmlfnpdbvtntcwrvltgfnrgwttvvjhqljjvvnmztwgzcclgbjnjspzwnpgtgvhhhqbzrnvmdcljcdncvpnpdhrhqwvlhllbsrmjbzlgczwjsrvqrqfqmtjrnpbtdhsrfbhrgtgnrmlgcwcmrvrdfcqbfcqczjchgrjpzqfqqmcpvnvbrssfrfsrjmlngplqqsnclgvpfhjbzdppjftlgbmcgdbrvqrclvtdnzhhcmzlrdrgbrqrlvfcnvznnqwswvhdpbbjmsqzcrmjngzmdftjzsjvgfdtcvdwhnwwjlcgcmflzzpzpgzrvmptbjgrdjbzscrglhcjppdjdshnvvbsnnddtbwsdrpnbnlrtppcrzbbjrfzhbwgmjqtmgjvmrjgfdndlmqvhgwprsjnhcmrnfdfdzggjjzcccnsnwwbjzmsfjjfhclptfcwqjhnphpwzszjmsrtnbqpqsvcfcvrrgclwlbrqngdcdlzrdfpvbgtznjzdvjngrgswhjnrpgswtqflpgvnpbsvcrtgtzcbhdjpbjwnpdzcmprtzlppbqvpzrrlbssmwhhvqqpmwggnzwcfdnzccjrrncnvjqgbpstctwpqvhdsbcsjrpbzbdlwwvjngtbnvpthppglgsnrbwnvpzldhsgwqhclgwrdsvcfdclvdsbrhcfnbgrtqswstnjfmfrdgphpvgjfqzcwnpcghdhtflgdnhhnnnwrpnmppszgqdcqjqpnccfsqjsmwtqvzwfqvtwtthwswmcqqcqjwcgwgzgmnpzbfpzrqbvqhbhtsvvbppbmqzfnsmwppzvsctgcncztsqdfhnlwjjtvwcchvnphwpnpzqsjhlrcmnbthtqlfclnsfdtpwfzljdpfszvhgzdpzhbjtphbfbmwgfrfplntfqhgpbjzghmblzzhdcbptngqwrtfmvtbhphpvdwpswbscrwzhnvqfwlbwwqqgstgmbqlllspbhbpjmmrfhmjwzdnsdwmpvlrspgzmdjwqwcjpbgwspsghjdvrbbsbtgwptqdvvdhbhqbdhpbzdsdwsjdbjnztdqqrdhwhtpvcbblbmjgmbpqghdsfthzjffrdvldfsnpcsmnzwzcqlnvcrcbqnfcdrfbffrvhqsbqjnnbzsqvqqdqwmsvbqvtgmnnlthpngfsljqnrdhhzpmwsnqvrgdnvlbgnndfcpjfgmzqssvnnrwbmslcqpnhnnwzggsjvqcsqpfzjcmcppntmsdtfggzdncqbfjsqvbzgnnlsdbgjqffsmvnbqlsrjwdmcjbrsrpchnnhdtlcdhfdltmlvtrwjpzphtbhzzrlrwbbhhpntgbcfmphnbrjdhrhvmvhfglrncngjdsvbfrqtqzsgvlzjqzcqnwdcfgvnpsqpphwfsdvpgnchjnnjhsqgvlqcvhzzzcrsqcvrbsbjbdbgddlbb
""";
#endregion
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,314 +1,221 @@
using Spectre.Console;
using System.Buffers;
using System.Numerics;
using Spectre.Console;
namespace AdventOfCode.Days;
public class Day8 : Day
{
public override int Number => 8;
public override string Name => "Treetop Tree House";
public override string Name => "Playground";
public override void RunPart1(bool display = true)
{
var grid = CreateGrid();
var boxPositions = ParseBoxPositions(Input);
var boxPairDistances = FetchOrderedDistances(boxPositions);
var valid = new HashSet<(int, int)>();
var circuits = new List<HashSet<Box>>();
// Check each line from left to right
for (int i = 0; i < grid.GetLength(0); i++)
var connectionsCount = 0;
while (connectionsCount < 1000)
{
int previousTreeSize = -1;
// Fetch next minimal distance pair. This is always the last pair in our ordered list
var (pairLeftBox, pairRightBox, _) = boxPairDistances[^1];
boxPairDistances.RemoveAt(boxPairDistances.Count - 1);
for (int j = 0; j < grid.GetLength(1); j++)
// Create a connection if those two boxes are not already connected
if (!ConnectionExists(circuits, pairLeftBox, pairRightBox))
{
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;
// Connect the boxes, eventually merging circuits
ConnectBoxes(circuits, pairLeftBox, pairRightBox);
}
connectionsCount++;
}
var result = circuits
.OrderByDescending(circuit => circuit.Count)
.Take(3)
.Aggregate(1, (product, circuit) => product * circuit.Count);
if (display)
{
AnsiConsole.MarkupLine($"[green]Total viewable trees: [yellow]{valid.Count}[/][/]");
AnsiConsole.MarkupLine($"[green]Result is: [yellow]{result}[/][/]");
}
}
public override void RunPart2(bool display = true)
{
var grid = CreateGrid();
var boxPositions = ParseBoxPositions(Input);
var boxPairDistances = FetchOrderedDistances(boxPositions);
var maxScenicScore = 0;
var circuits = new List<HashSet<Box>>();
// Compute scenic score for each tree
for (int i = 0; i < grid.GetLength(0); i++)
long result;
while (true)
{
for (int j = 0; j < grid.GetLength(1); j++)
{
var size = grid[i, j];
var score = ComputeScenicScore(grid, i, j, size);
// Fetch next minimal distance pair. This is always the last pair in our ordered list
var (pairLeftBox, pairRightBox, _) = boxPairDistances[^1];
boxPairDistances.RemoveAt(boxPairDistances.Count - 1);
if (score > maxScenicScore)
{
maxScenicScore = score;
}
// Create a connection if those two boxes are not already connected
if (!ConnectionExists(circuits, pairLeftBox, pairRightBox))
{
// Connect the boxes, eventually merging circuits
ConnectBoxes(circuits, pairLeftBox, pairRightBox);
}
// Check if there is a circuit with all boxes connected
if (circuits[0].Count >= 1000)
{
result = pairLeftBox.X * pairRightBox.X;
break;
}
}
if (display)
{
AnsiConsole.MarkupLine($"[green]Max scenic score: [yellow]{maxScenicScore}[/][/]");
AnsiConsole.MarkupLine($"[green]Result is: [yellow]{result}[/][/]");
}
}
private int ComputeScenicScore(int[,] grid, int i, int j, int size)
private static double BoxDistance(Box left, Box right)
{
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;
return Math.Sqrt(
(right.X - left.X) * (right.X - left.X) +
(right.Y - left.Y) * (right.Y - left.Y) +
(right.Z - left.Z) * (right.Z - left.Z)
);
}
private int[,] CreateGrid()
static bool ConnectionExists(List<HashSet<Box>> circuits, Box left, Box right)
{
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++)
foreach (var circuit in circuits)
{
for (int j = 0; j < grid.GetLength(1); j++)
if (circuit.Contains(left) && circuit.Contains(right))
{
grid[i, j] = int.Parse(lines[i][j].ToString());
return true;
}
}
return grid;
return false;
}
#region Input
static void ConnectBoxes(List<HashSet<Box>> circuits, Box pairLeftBox, Box pairRightBox)
{
// Try to find circuit containing each box
HashSet<Box>? leftCircuit = null;
HashSet<Box>? rightCircuit = null;
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
""";
foreach (var circuit in circuits)
{
if (circuit.Contains(pairLeftBox))
{
leftCircuit = circuit;
}
#endregion
if (circuit.Contains(pairRightBox))
{
rightCircuit = circuit;
}
}
// None is in a circuit, create a new one
if (leftCircuit is null && rightCircuit is null)
{
var circuit = new HashSet<Box>
{
pairLeftBox,
pairRightBox
};
circuits.Add(circuit);
}
// One of the two is null
else if (leftCircuit is not null && rightCircuit is null)
{
leftCircuit.Add(pairRightBox);
}
else if (leftCircuit is null && rightCircuit is not null)
{
rightCircuit.Add(pairLeftBox);
}
// Both are already in a circuit, merge them
else
{
foreach (var box in rightCircuit!)
{
leftCircuit!.Add(box);
}
circuits.Remove(rightCircuit);
}
}
private static List<Box> ParseBoxPositions(string input)
{
var positions = new List<Box>();
foreach (var line in input.EnumerateLines())
{
var split = line.Split(',');
split.MoveNext();
var x = long.Parse(line[split.Current]);
split.MoveNext();
var y = long.Parse(line[split.Current]);
split.MoveNext();
var z = long.Parse(line[split.Current]);
positions.Add(new Box(x, y, z));
}
return positions;
}
private static List<BoxPairDistance> FetchOrderedDistances(List<Box> boxes)
{
var boxPairDistances = new List<BoxPairDistance>();
for (var i = 0; i < boxes.Count - 1; i++)
{
for (var j = i + 1; j < boxes.Count; j++)
{
var leftBox = boxes[i];
var rightBox = boxes[j];
var distance = BoxDistance(leftBox, rightBox);
boxPairDistances.Add(new BoxPairDistance(leftBox, rightBox, distance));
}
}
// Sort in reverse order
boxPairDistances.Sort((left, right) => right.CompareTo(left));
return boxPairDistances;
}
private record Box(long X, long Y, long Z);
private record BoxPairDistance(Box Left, Box Right, double Distance) : IComparable<BoxPairDistance>
{
public int CompareTo(BoxPairDistance? other)
{
if (ReferenceEquals(this, other))
{
return 0;
}
if (other is null)
{
return 1;
}
return Distance.CompareTo(other.Distance);
}
}
}

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

136
Inputs/Day4.txt Normal file
View File

@@ -0,0 +1,136 @@
@..@@.@@.@@@@@....@.@@.....@@@@.@.@@@@@.@.@.@@@@@@@@...@@..@..@@.@@@..@.@@@@.@@@@.@..@@....@.@.@.@@@...@@@.@@...@@..@@@..@@.@@.@..@.@@@.
@@@..@@@.@@@@@@@@@@..@@.@@@.@@@@@@@@@..@.@@@@....@.@.@@@@.@@@@.@@.@@.@@@.@.@@@.@@...@@@@.@@@@@@@@@@@.@@@@@@@@@@.@@@@@@@.@@@@..@@@@@...@.
@.@@@@..@@@@@....@@@@@@..@@@.@..@.@.@@@.@@..@.@.@@@.@@.@@@@@@@.@@@..@@@@@..@.@@.@@.@.@.@@.@.@@.@@@@@@@@.@@@@@@.@.@@.@@.@@@@..@.@@@@@...@
@@@@@@@.@.@@@.@.@@@.@.@@@.@@.@@...@@@@@.@.@.@@@.....@@.@@@@.@@@.@.@.@@@@@@.@@@@@.@@@@.@..@@.@@@@@.@@.@@@@.@.@@@@@@@.@@@@.@@@@@@.@.@@@.@.
@.@@@@.@@@.@@@..@...@@@@..@..@..@@@@....@@@@.@@@@@@@.@.@@@.@@@@..@@@@..@@...@.@@@@@@@@@@@@@@@.....@@...@@@.@.@@...@@@..@@.@@@@@@@@..@@..
@@@@.@..@@@@..@@...@.@..@@@.@@..@@@@@...@@@.@@@.@....@.@.@.@@..@@..@..@@.@@@...@@@...@@@@....@@@..@..@....@@......@@..@@..@@@@@@..@@.@@.
.@@@@.@@@@.@@.@@@.@.@@@@@@.@..@@..@@@@.@@.@@..@.@@.@..@@@@@@.@@.@@@..@.@@....@@@@@.@@..@..@.@@@@.@....@@@.@....@.@@@@@@@@@@.@.@@@@...@@@
@.@@...@.@@@.@.@.@@.@@@@@..@.@@@@@.@@.@@@.@..@@@@..@.@@@..@@@@.@@.@.@@.@@.@@.@.@.@@@@@@@@@.@@@@.@@@@@@.@...@..@..@@.@@.@@@@@@@@@.@.@..@@
@..@.@.@@.@@@@@@@@@@@@..@@..@@.@@@..@@@.@..@@...@.@.@@.@@..@..@@@@.@@@.@@@@.@..@.@..@@@@@@.@.@@.@@@@.@..@@@@@.@@@..@@....@@@.@@.@.@@@...
@@.@@@@.@..@@.@.@.@@.@@@..@@..@@@@@..@@.@.@@@@@..@..@.....@...@@@@@@@@@@..@@@@@@@@.@@@.@..@@@@@@@.@@......@@@...@...@...@@@.@.@.@@@@@@@@
@@@@@....@@@@@.@@.@@@@@@..@.@.@...@@@@@.@.@@@@........@.@.@@@@.@..@@@@..@@@@.@@.@@@.@...@@@@@@..@@@@@@.@@@@@@.@.@..@@@@...@@.@@...@..@.@
.@@@@@@@@@.@..@@@..@@@@@@@@.....@..@@@@@@.@...@.@@@@@.@.@@@.@.@@@@.@.@.@.@..@.@@@.@@@@..@.@..@@@@@@@@@@@@..@@@.@.@@@@@@@@@.@..@.@.@@@@@@
@@@@@@@@...@@.@@.@@@@..@@@.@@@@@@@@@@.@@@..@@@.@@@..@@..@..@@@@.@.@.@@@@.@@....@@@@.@.@.@@@@@@.@@@@..@@@.@@@.@@@..@@@@.....@@.@..@.@@.@@
@.@.@@@@....@....@@@@@@@.@@@.@.@@@@@.@.@..@@@.@@@@@.@@@@..@@.....@@@@.@@.@@@..@.@@...@@@.@@.@@@@.@.@@@.@@...@@@.@@@..@..@@@..@@.@@..@@@.
@.@@@@@@...@.@@@@@@@..@..@@.@@.@.@..@@.@.@@..@.@@@.@@@@@@.@@@@.@...@@@@@.@@@.@.@@@@..@@@..@@.@@@.@@.@@@..@@@.@.@@@@@@@..@@.@@.@@@.@.@@..
@@....@@@..@@@@@.@@.@@@@@.@.@@.@@@@@@@@@.@@@@@@..@@@@.@@.@.@@...@@..@.@@@@@@@@@@@@@@@@..@@@@@@...@@@@@@@@@..@@@@@@@@@..@@@@.@@.@.@.@@@@.
..@.@@@@.@@@@.@..@@@@...@@.@@...@@..@@@@@@.@@....@@..@@@@@@.@@@@@..@..@@@.@@....@@.@@@..@.@..@.@.@@@@.@@@@@.@@...@@@@.@@..@@@@@@.@@@.@..
@.@...@@@@.....@@@@..@@.@@@@@@@.@...@@@.@@@@@@.@.@@@@.@@@...@.@@@@@@@..@@@@@@.@@@@@@@.@.@@...@@@@@.@..@@@@@..@@@.@@@@...@@@@@.@.@.@...@@
.@@@@@..@@@@@@@.@@@.@.@.@.@@@....@@@@@@.@@@@@.@..@.@@@@.@@..@@@@@.@@@@..@.@@@@@@.@@@@@@....@@@@.@@@@@@@@@..@.@..@@@@.@@@@@@...@@@@..@@@@
@@.@@@@@.@@.@@@@@@.@@@.@.@@..@@@@.@@.@@@.....@.@@.@@@@@@.@@@...@@@@@.@@@.@@..@@@@@@@@@@@@@.@@.@....@@@.@.@@@@@@@@.@.@.@@.@@@@.@@@@..@@..
@.@@@..@@.@.@.@@@@@..@@@@.@....@.@@@.@@@.@@.@.@@.@@.@@.@@..@@@.@@@@..@@@.@@.@@@@@@@@@@.@.@..@@@@@@.@@@@@@@.@..@.@@@.@@.@@.@..@.@@@.@.@@@
@@.@.@@@@@@.@....@@@@@@@.@@.@@@@@@@@@@.@@.@.@@@..@@@@@@..@@..@.@.@@@@..@@@.@@..@@@@@@@@@...@@.@@@@@.@@@@@..@..@@.....@@.@@@@..@@@.@@@..@
@@@@.@.@@.@@@@@@@@@..@.@@@@..@.@@..@@@@@@@.@@.@..@@@@@...@@@@@@@@@.@.@.@@@@@.@@...@@.@.....@@@.@@@@@.@.@@.@@.@.@@@..@.@..@@@@.@@@...@@@@
@@@...@.@@@.@@@.@@@@@@....@@.@@.@.@@@@.@@@@@.@@@@.@.@.@@.@@....@.@@@@..@@......@@.@@@@@@@@@@..@@.@@.@@@@.@@@.@@@..@.@.@..@@..@.@@@..@..@
@.@@@@@@.@@@.@@..@.@@@@@.@@@@@...@..@..@@@@@.@..@@@.@..@@@@.@@.@@@@@@.@@.@@@.@@.@.@..@...@@@@@.@@@@@@@@@...@@.@.@...@...@@...@..@@@.@..@
.@@@..@@....@...@@.@..@....@@@@@@.@.@...@@.@@@.@@@.@.@.@@@...@.@@@.@@@.@@.@@@..@@@..@....@.@@@@.@@@@.@.@.@@..@..@..@@...@.@.....@@@@@@@@
.@@..@@@.@@...@@@@.@@@@@@.@@@@@@@.@@.@@.@@@@@@....@@.@.@.@@@@.@.@.@...@@@@@@.@.@@.@@@.@..@@@@.@@@@@.@..@@.@.@..@.@.@@..@@@@.@.@@@@.@.@.@
@@@.@@@@@@..@..@@.@.@@@..@@@@@@.@@@.@.@@@@@@@@@@@@@@.@.@@@.@@.@@@@@.@.@.@....@.@@@@..@..@@.@@@@@@@@@@@.@@@@...@..@.@@@...@@@.@@@..@..@@@
@@.@@@@@@..@@.@@@@@..@@@@@@@@.@@@@@@@@..@.@@@@.@@@@.@@@@@.@@@@@@@.@@..@@@@@@@@@@@.@@@@...@.@..@.@..@.@..@@@@...@@@@@@.@@@.@@@@@.@.@@@@.@
@.@@@...@@.@@.@@@.@@@.@@...@.@@@@@@..@@.@@@.@@@.@.@@@@@..@@@@@@.@.@.@.@@@@@..@@..@@.@@.@..@.@@.@@@..@...@@@..@@...@@..@@@..@@@@@@@@@@.@@
@..@..@@.....@@..@.@.@@@@@.@@.@@.@@@@@@@@..@..@@.@..@@....@@.@@@..@@@@.@@...@@@@@.@@@.@@..@.@@@.@@@@.@@..@@@@@..@.@...@.@@@@.@.....@@@@@
@.@@@.@@@@@@.@@..@.@@@@@@@..@@.@@.@...@.@@....@@....@.@@@@@@@@.@@@@.@@@@@@@..@@@@.@@@@@.@@.@.@@@.@@@@@.@.@@@@.@...@@.@.@..@..@@@@@@.@..@
.@..@..@.@.@@@@@@.@@@.@@@@@@..@.@.@@@.@@@@@@@@.@@@@.@@@.@@@.@.@@.@..@.@@.@@@@@@@.@...@@@@.@@@@@@@.@.@.@@@.@@@...@@@.@@@@@@@@.@...@.@@@@@
.@@@@.@@@.@.@@@@.@...@@@@@..@@.@.@@@@.@@@@@@@..@.@..@@@@.@@@@@@@.@@..@@@@..@@.@.@.@@@@@@@@@@.@@.@@@@@.@@@@@@.@..@.@...@@@@.@..@@@..@@@.@
@....@..@.@@.@..@...@..@@@.@@@.@..@@....@@@.@@.@@@@@@.@@..@@@.@@...@@@@@.@.@@@..@..@.@@.@@@.@@@.@@@.@@@@@@@@@.@@@@@@@.@@@.@.@.@@@..@@@.@
@@@@@@...@@@@@..@@.@@@@@@@.@@.@@@@.@@@@@@@@@@....@@@@@@@.@@@.@@.....@@@.@@@@..@..@@@@..@@..@@@@.@.@@..@.@@.@..@...@@@@@@.@.@..@@.@@..@.@
@@@@@@@.@@@@@@@@@..@@.@.@.@@@.@@@@@.@@@.@@@.@.@@@.@..@.@@@.@.@...@@@@@.@@@.@@..@..@.@@@@@.@@@@@.@.@@.@@...@.@@@@@....@@@..@.@.@@.@@.@@@@
@@@@....@.@@@@.@@..@@@@@..@@.@@@.@@@...@@@.@@@@@....@@@@.@@..@.@.@.@.@@.@...@@@@@@@.@..@...@@...@@@@@@..@.@@@.@.@@....@@@.@@@@@@.@.@@.@@
....@.@@@..@.@@@..@@@@@..@...@.@@@.@@@@@@@..@@@@.@.@...@@@..@@@@..@@..@.@.@@@.@.@@..@.@..@@.@@.@@.@.@.@.@..@@@@@@.@@@@.@.@@@@@..@@@@@@.@
..@.@@@..@...@@...@..@@.@.@@@@.@@.@@..@.@@@@..@@...@@@.@@.@.@@@@@@@.@@.@@.@@..@.@@@@.@@.@@@@..@@@..@@@@@@@...@@..@@@@..@@.@@@.@@@..@@.@.
@@@@@.@.@@.....@@@.@@@@@@@.@@@@@.....@@.@@@.@@.@..@@@@@@@@.@@@.@@.@@.@@@.@@@@@@@@.@.@@.@@@.@@@.@@.@.@@.@@@@.@@..@@@@@@@..@@@.@@@@@.@@@.@
..@.@@@@@.@.@@.@@@@.@@@@@@.@.@...@....@@@@@..@..@@@@.@.@@@.@.@....@@.@@@@@...@@..@@.@@@@.@@@..@.@@@@@@@.@.@.@@@..@@@.@@..@....@..@@@@...
@.@.@@@@.@@..@@.@.@@.@@@@..@@@.@@@.@@@@@@.@@@@@@@.@@.@@@@.@@.@.@.@@@@@..@@@@.@@.@.@@@@...@@@.@.@@.@@@@@@@.@.@@@.@@@@.@@@......@.@@@@.@@@
@..@@@.@@@..@@@..@@@@@@@.@@@@@@.@.@@@@@@.@.@@.@.@...@....@..@@@@@@@@@.@...@@@....@@@@@@@@.@..@@@.@.@.@@.@.@.@@@.@@@@@..@@@.....@.@@.@...
@.@.@.@..@@@..@@....@@..@.@@.@.@@@@.@@@@@.@@.@@.@@@@@@.@.@.@@.@..@.@.@@@@.@@.@.@.@@@@.@.@@..@@@@@..@@@.@....@@.@.@@@@.@...@@@..@@@@.@@..
@.@.@@@.@..@@@@.@.@@..@.@@@@@.@@....@.@@..@..@..@@@@@@.@@.@@@.@..@@@@@@..@.@@.@.@@.@@.@@.@@.@@.@@@@@@@@@@@.@.@@@@@..@@@@@@@.@....@@@...@
@@.@@@@..@@@@@@..@.@@@@@@@@..@..@@@.@.@@@@@..@@@@@.@..@@@@@@@..@.@@@@@@@@...@.@.@@@@..@@@@@@.@@..@@.@@@@@@@.@@@@@..@.@@.@@.@@.@@..@.@.@@
.@@@...@@@@@@@@..@.@@@@@...@.@@@@@@@@@@@.@@@@@@@.@.@@@@@@.@@@@.@@.@@@.@@@@.@@@@@@@@@@@@.@@@@@@@.@@.@.@.@@.@@@@.@.@.@@@@.@@@@@..@@@...@..
@@..@@@@.@@.@@@@@.@.@@.@.@@.@@@@..@@@.@.@.@@@@@@@@@..@@@@@.@@@@.@.@..@@.@@@..@.@.@@@...@@@.@.@..@@@..@@@.@..@@@.@@@@.@@.@@.@@..@.@@@@@@.
.@.@@..@.@@@.@...@@.@@@@@@@@@@@.@@@@@.@@@@@@@@..@@.@.@@@.@@.@.....@@...@@@@@@@.@@@@.@.@@..@@.@@@.@@@@.@@@.@@.@@.@@..@..@.@@.@@@@@.@@@@@.
@@@@.@@@@.@@..@@....@@@@..@.@@.@.@..@.@@@@@..@@@.@@..@.@.@...@....@.@..@@.@..@@.@@@@@@@@.@.@.@.@@@.@@..@@@.@.@@@...@@@@@.@@@@.@..@@@@@@.
...@.@@@@@@@@@@@@@.@@@@@@.@@@@@@@@@@@.@@@@.@.....@@@..@.@@.@@.@@@.@@@@@.@@.@@@.@@...@.@@..@.@@.@@@@@.@@@@@.@@@@.@@@.@@.@@.@@.@..@.@@.@@@
@@...@@@@..@.@..@..@@.@@@.@@.@.@..@@@.@@.@@.@...@.@.@@@..@@@.@@@@.@@.@..@@@.@@@.@@..@@@@@.@@@.@.....@@@@.@@@..@.@@@@@.@.@@@...@@@@@..@..
..@@.@..@@@@...@..@@@.......@@@.@@.@@@.@@@.@@@@.@.@...@@@.@@@@...@@...@@.@@.@@@@@@@@@@.@@@@@...@...@@@@@.@..@.@@@.@@@@@@.@@...@@@..@.@@.
@@@@@...@@.@@.@@.....@@@@...@...@@@@.@@@@@.@@@@.@@@@.@@.@@@..@@@@@@@@.@@@.@@@@..@.@@@@@.@.@.@@..@@.@@@.@@.@@@@@@.....@.@.@.@@...@.@@@@@.
@@..@@@@@@@.@@.@@...@@@@..@@.@.@.@.@@@.@.@...@@..@@@@@@@.@...@@@.@@@@@.@@.@.@@@@.@.@.@.@@.@@@@@@@@@@@.@.@@..@..@...@@..@.@.@.@@@.@@@@@..
.@.@..@@@@@@@@.@..@@@.@@@@..@.@@..@@@@.@@@@...@@..@..@.@@@@...@.@@@@.@..@@.@..@.@@@@@.@@@@.@.@@@@@.@....@.@@@.@@@.@@@@...@.@@@..@....@@@
.@@@@@..@...@@@@@@@@@@@@@@@.@@..@@@..@@@@....@.@@@.@..@@..@@....@@@@...@@@.@.@@@@.@.@@.@....@..@@..@@@.@..@@..@@.@..@@.@.@..@.@@...@@.@@
@@@@@.@@@@.@..@.@@.@@@@@@.@@@@@@@@@@.@@@@.@@@...@@@.@@@@@..@@.@@@..@@@.@@.@@.@@.@@@..@@@@.@@.@@@@.@@@@.@@.@@@.@..@@..@@@..@@@.@..@@@@@@.
......@@@@@@@@@@.@@@@@@@.@@@@@@..@.@.@@@@@@@@@@@@..@@@@.@@@@@@@@@@@@@.@@@@@@@@@@@@.@@@@@.@@....@@..@.@.@..@@...@@.@@@@@@@@@@@@.@...@@@@.
@@@.@.@.@..@@@@.@....@@@.@@@@.@..@@@..@@@@....@@.@@.@@@@.@@@@.@@.@@@@@@@@@.@.@@.@.@.@..@@@..@@@.@..@..@..@.@@@@.@@@@@@...@.@@@@@.@@@.@@@
.@@.@@@@..@.@..@@@.@@@.@...@@@.@@@@.@.@@@@@@.@@@..@@.....@@@@..@.@.@@@@...@@@@@@@...@@@..@@..@@@@@@@@.@@...@@..@@@.@.@@@.@@@.@@@.@..@@@@
@@...@@@@@.@@..@@@..@@@@@.@..@@@@@@.@.@..@.@@@@.@@@@..@@...@..@@@.@@@.@.....@@@@@@@.@...@.@..@.@@...@..@@..@@@.@.@@@.@@@...@@@@.@@.@@.@@
@@@@@.....@.@@.@@@@.@@@@.@@@@@..@@.....@..@@.@@@@.@@@@..@@@.@.@@.@.@@..@.@@@.@.@.@..@@...@@.@@@@@@@.@@@..@@.@@@@@@@.@.@@@@..@..@@.@@.@..
.@@@@...@.@@.@@@..@@@@@.@.@@@@.@....@.@.@@@@.@@@.@@..@@..@@@@.@@.@@@..@....@@..@@@.@@@@@.@@@.@.@.@@...@.@...@@.@@@.@..@@@@@.@..@@@..@.@@
..@.@@@.@@.@@@.@@@@@.@@@@@@.@@@@.@@.@@@.@@@.@..@@..@.@@@.@.@.@@@...@@.@@.@.@@@.@@@.@.@@@@@@@@.@..@@@@@.@..@.@@@@@@@..@@..@.@@.@@@..@.@@@
.@.@@.@@@@@.@@.@@.@@@.....@@@@@@....@@@@@@@@@@@@@..@..@.@@@@@@@.@.@..@..@@.@@.@.@@.@@.@@.@.@..@...@@@.@@@.@..@@...@@@@@..@@@.@.@@@.@..@@
@@@@@.@.@@@..@@@.@@.@..@@@.@@@.@..@@@@@@@.@@.@@@@@@.@@@.@..@@.@@.@@..@@@@....@..@@.@@@@@@@@..@@.@@@.@@....@@@.@@.@@.@.@@@@@@.@.@.@@@..@@
...@@@@..@@@@.@@..@@.@...@..@@@@@..@.@@@..@.@.@@..@...@.@@@.@.@.@@@@@.@@.@.@@@@@@..@@..@.@@@.@.@.@.@@@.@@@@.@.@@@@...@.@@...@@@@@.@..@.@
@.@@@.@@..@@..@.@..@.@@@@@...@@@..@@..@@@@@@@@@@....@.@@@@.@@.@@@@@@@@@@@...@@@@.@@@.@.@@@@@@@@@@@@@@.@@....@@@@@.@...@@.@..@.@.@@@..@@.
@@@@.@@.@@@@@.@.@@@@.@@@.@@@@.@@@@@..@.@@.@...@@........@@@.@@@@@@@@@.@@.@@@@.@@.@@@@@@@....@@@@@@.@...@.@@.@@.@@.@.@@..@@@.@@@.@@@@@@@@
@....@.@.@@@@....@@@@@.@.@@.@@@.@@@@.@..@.@.@.@.@.@@@....@@@@@@.@@@@@..@@@@@.@@@@@@..@@@@@@.@@..@.@.@@.@@....@@.@@@@@@..@@@.@.@...@@...@
@@.@@..@..@.@@@@@@@@..@@@@@.@.@@...@@@@@@..@@@.@@@@.@@@@@@...@.@@@.@@.@@.@@.@@@..@..@.@@.@..@@@.@@@@.@@@@@@@.@@@@@@@@.@.@@.@@@@.....@@@.
.....@@@@..@.@@@.@@.@@@.@.@..@@..@@.@@.@@@@@@@.@@@@@.@.@@@@...@..@..@.@@@@.@@@.@@@.@@@@@@@@@.@@@@.@@@@.@@@@..@.@.@.@@@@@@@@..@@@@..@@@..
@@@@@..@@@@.@@@@@@@@..@@@.@...@@@@@@@@@..@..@....@@@@.@.@@@.@.@.@.@.@@@@@@.@@@.@.@@.@@@@@@@.@@@@.@@.@@@.@@@..@@@.@....@......@@@@@@.@.@@
....@.@@@@..@@@@@@@@@..@@@@.@@@.@@.@.@@@@@@@@@.@@@@@@....@.@@@@.@.@@..@.@.@@@@.@..@@@.@.@@..@.@@@@.@@@@@@@@@.@@...@@..@@@@.@.@@.@@.@@@@@
.@@.@@@..@@.@@@@..@.@@@@@@.@.@...@@@@...@@@.@.@..@@@@@.@@@@.@@@.@@@.@@@@@@@..@@@@.@@@.@@@@@@@@@@@@@.@.@@@.@@.....@@.@@@.@@.@@@@@@@.@@.@@
@.@..@@@@@@@@@..@@@...@.@...@@@@.@@@@..@@@@@@@@@.@@@@@@@@.@..@@@...@@@@..@@@@@.@....@@@..@@@@.@@@.@@@@.@@@.@@@@@.@.@@@@@@..@@@@..@@....@
...@..@@@.@.@@@@.@.@@@.@..@.@@..@.@@...@@..@@@@.@...@@.@@..@@@@@@.@...@@@....@@.@@@@.@.@.@@@.@.@.@.@.@@@.@@@@@@..@@@@@...@@...@.@@@.@@@.
.@.@...@@@.@@@...@@..@@@.@@@@@@@@@..@....@@@.@@.@@@..@@@@@.@@@.@.@.@@@.@@.@@.@...@@@@...@@@..@@@@@@@.@.@@.@@@@@@@.@@..@.@.@@@@@.....@@@@
@.@.@@..@.@....@.@@@@.@.@@@.@@@@.@@.@.@..@@.@@@@@@@@.@.@.@..@@@@.@@...@..@@@@.@@@...@.@@..@@..@.@..@..@@@..@@@@.@@@@@..@.@@@@@...@@.@@@@
@@@...@@@.@.@..@...@@@@..@@@@@..@@@@@@.@@@....@@.@.@@.@.@@@.@@@@.@..@@.....@@@@@.@@@@@@.@.@@@@.@.@.@@@@@@@@@@@@@@@@@@@@...@@.@@@.@..@..@
@@@@@@..@@@@@@@@..@@@.@.@@@.@@@@@@@....@@....@@..@..@@@@@@.@.@@.@@.@..@@@....@@.@@@.@.@@.@@..@@@@@@.@.@@..@.@@.@.@@..@@@.@@@@@@.@...@@@.
@.@..@@..@@@.@@@@@.@.@.@@@@.@@@.@.@.@@@@@...@@@.@.@@.@.@@.@@...@.@@..@@@@@..@@@.@@@@@.@.@@@@@@@@@.@@.@@@@@@@@@..@@..@.@@@@@@@@@@....@@@@
.@@.@@..@@@.@@@@@....@@@.@@@@@@.......@@..@.@....@@.@@@@@@..@.@@@.@@@@@.@@.@@@@@....@@.@.@..@@@..@.@...@@.@@@.@@@@..@@.@..@.@@@..@@@@@.@
@@@@.@@@.@@.@@@@@@@@@.@.@..@@@.@..@@.@@..@@@.@@.@@@@....@.@@.@.@@.@.@@@@@@@.@@@@@@@@@...@.@.@@@@@@@.@@..@..@@@.@.@@@@@@@@.@.@@.@@@@.@..@
@@@@.@.@@@@@..@@.@@@@@@@@.@@@.@.@.@@@@@.@@@@@@@@@..@@....@..@@@.@.@.@@@@@@.@@@..@@..@@...@@..@@@.@@...@@.@@@.@@@@@@@.@@.@@@@.@@@.@@.@@.@
@......@..@@@@@.@..@.@@@@.@.@@@.@@@@.@.@@@@@@@.@@..@.@@..@.@.@@.@@@.@.@.@@@.@@.@@@@@@....@@@@..@@@@@@...@@@@@@@..@@@@.@@@.@@.@@..@@.@@.@
@@@@@@@@@@@.@...@@@@@@@@@@@@@@@@@@@@@@@@...@@@@@@@@.@.@.@@@@@@@@@@@@@@@.@@@.@..@.@@@.@.@@@@@@@@.@.....@..@@.@@@@@@@@..@@@..@@@@@@@@@@...
.@@.@@.@@.@@@@@.@@@@@@@@@@@@.@@@@@@@.@@@@..@@@...@@@..@@@.@.@@@@@.@.@@@@@@..@@...@@.@.@@@@@@.@@..@..@..@@@.@@..@.@@@@.@@@.@@@@@@....@.@@
@..@....@.@@.@..@@..@@@@.@..@@@.@..@@@..@.@@@..@..@.@.@@@@.@.@.@@@@@@@@@@@@.@@@@@@.@@@.@@@.@.@..@@@.@@@@.@.@@@......@@.@.@@.@@.@..@@...@
@..@@@@@@@..@@@.@@@@@@.@.@@@@@@@..@@@@@@@..@@@@@@.@@.@@.@@.@.@@@@@@.@..@@@@..@.@.@@@..@.@.@.@..@.@.@@..@@.@.@@@@@@.@.@.@@.@.@.@@@@@.@@@@
.@.@...@@@@.@.@@@@@@@..@@.@..@@.@@.@..@@@@.@@@@@@.@...@.@...@@@@@@.@..@@@@..@.@..@.@.@.@@@..@..@..@.@@..@@@@.@@.@@.@@@@@@@..@.@.@@..@.@.
@@...@@@.@@.@@@@@@@@@.@.@@@@.@@..@.@.@.@@.@.@@@@@@@.@.@@@@@@..@@.@.@.@@@.@@@@@@@@@@.@@@@.@@..@@.@@@@@....@@@@@.@@@..@@.@...@@@@@@.@@@.@@
...@...@.@@.@.@@@@@..@@.@@@.@.@@@.@@@@@.@@.@..@.@@.@@@.@@@..@.@@@@@@@@@.@@.@@.@@@.@@@.@@@.@@.@@.@.@@..@.@@@@@@@@.@@@@.@.@..@@.@@@...@.@.
.@....@@@@.@.@@@@@.@@@..@.@..@@@@..@@@..@@@.@@@.@@@..@..@..@@...@@.@@@@@@.@.@@@.@@@@@@@@.@@@@@@@@.@@@@@.@@.@@@..@.@@@@.@.@@.@@@@.@@.@@@.
.......@...@@@@@@@@@@@@..@@@@@@@@@@@@@@.@.@.@..@.@@@@...@.@@@.@@@@...@@.@@@@.@@@@@@@@.@@.@.@.@@@@@..@@.@@@.@@.@@@.@..@..@@@@@@.@@@..@.@.
@@@@.@.@@@@@@...@@..@@@@@@@@@.@@.@@@..@@@@@@..@@@@..@.@..@@.@.@@@@.@..@@.@...@.@@@@@@@@@@@@@.@@.@@@@.@@@...@@.@@@@@.@@.@@@..@@.@@@@@@.@.
@@@.@@@..@@@@@@@@@@@@@.@@@@.@..@@@@@@.@....@@@@@@@.@@@..@@@@..@...@@..@@.@@@@.....@@.@.@@@@@@@@@@..@@@.@@@..@@@@..@@@.@@@@@@@.@@@...@@@@
@@@.@@.@.@@@@@@@@..@.@@..@..@@@..@...@.@@@..@.@@@@@..@@@.@@@@@@@@...@@@@.@@@.@..@@@.@.@@...@@.@@@@@@@.@@@.@@.@.@@@@@@@@.@.@@..@@@@@.@@@.
.@..@.@@@@@..@@@.@..@@@@@.@@@.@@@@@...@.....@@..@@@@.@@@.@.@@@.@.@.@..@@.@@...@@@@.@@@@.@@@.@.@@@@@@.@@@.@..@.@@.@@@@.@.@..@@@@@@@..@.@.
.@@.@@.@..@.@.@@...@@@.@..@..@.@.@@@..@.@@.@@@@@@@.@@@@@@..@@...@.@@@@@@@@@...@@.@@@@.@@@@@@@@@@.@@@.@.@..@@..@.@.@@@@@.@@@@@@@.@@@@.@..
@@@.@.@@@@@.@@..@.@@@@@@.@..@.@@@@..@@@@.@@...@@.@.....@@....@@.@@.@@.@@@@.@..@@.@@@@@.@@..@@@.@@...@@.@@@@@@@@@...@@@..@@@@@@@.@@@@...@
@@@@@@@@@@..@@.@@....@.@..@@...@@@@@@.@@@...@@@@.@@.@.@@.@@@@@.@.@@@@@@..@.@@@.@@@@.@@...@@.@@@.@.@@@..@@.@@@.@@@@@@@.@@@.@.@@@..@@..@@.
@@.@..@@@@..@@.@@@@..@@..@@@@@@@@@.@.@.@.@@@@@.@@@@@@.@.@@@@@.@.@@@@.@@.@....@.@@@@@@@@@@.@@@@......@@@@@.@@@@.@@@@@.@@@@@.@@.@@@@@@@@@@
.@@.@@@@@.@@.@@@@.@.....@@...@..@.@@@@..@@....@..@...@.@@@.@..@..@@@@@@..@@.@...@.@@@.@@...@..@@@@@@@@.@@..@..@@@@@@@@.@@.@@@.@.@@.@@.@@
@@..@..@.@@@.@@.@@@.@@@@..@.@@....@@@@@@.@.@@@@....@@@@.@.@@..@..@..@@@.@@.@...@.@@@@@@.@@@@.@@@@@@@@@@..@..@@.@..@.@@@@@..@@@..@.@@@@.@
@.@@.@@@@.@.@..@@@@@..@.@@.@@@...@@@@.@@.@@@@@...@..@@@@@.@@@@@@@@@@..@@..@@@.@.@@@.@@...@@....@@@.@.@..@.@@.....@@@@@.@@..@@@.@.@.@...@
@..@.@@.@.@@...@@@.@@.@@..@.@@@..@@@.....@@...@@@.@.@@@@@@@@.@@..@@...@@.@@.@@..@@@@.@...@@.@.@@@@...@@@@.@@..@.@@@.@@@@@@..@@@.@@@@.@@@
@.@@@@@@@.@..@@@@@@@@@@@@@@@@.@@@@@..@@..@.@@@@@..@@@@@@@.@.@.@@...@..@@@.@@@@.@@.@.@@...@.@..@.@@.@.@@@...@@@@@@@.@@@@.@@@@.@@@@@.@.@..
@@.@@.@@@@@..@.@.@@@@@@@@@@.@@..@@@.@.@@.@@@.@@@..@@...@.@@@.@.@..@..@@@.@.@@@@@.@@@@@@..@.@@@@@.@.@.@@@.@@.@...@@@.@@@@@@@.@@@.@.@@@@@.
...@@@@@@@.@@..@..@@@@@..@@.@@@@@@@@..@..@@@@.@@@@@.@@@.@@@@...@@.@@.@@@@@@@@..@@@@..@@...@@@@@@.@@...@@@@@@.@@...@@.@@@@@@..@@@..@.@@..
@@...@@@.@@@@.@@@@..@@.@.@@..@.@@@@.@.@@@@@@...@@@.@@..@@.@@@...@@@@.@@.@@@.@@@@@@@..@@@@@@@@.@..@@@@@@@@@@.@..@@.@@@..@.@@.@@@@@@.....@
@@...@@@@@......@@@@.@@@.@@.@.@@..@@@.@.@@@.@@@..@@@...@.@@@@@@@@@.@.@@@.@.@@..@.@@..@.@@@.@@.@@@.@@@@.@@@.@.@@.@@.@.@@.@..@@..@.@@...@.
@@.@@@@@..@@@@.@@@.@@@..@@@..@.@.@@@@@@@@@.@..@@@@@@..@@...@@.....@@@@@@@@.@@@@@.@@@@...@@...@@@@@@@.@.@.@@..@@.@.@@.@@@@.@@@@@@@@.@@@@@
.@@..@@.@@@.@@.@@@@..@.....@@@....@.@@@@@@@.@.@..@@@@@.@.@@.@.@..@..@@@.@.@@...@@@@@....@@.@@@@.@@@@@@@.@..@@.@.@@@@@@.@@@.@@@.@@.@@..@.
@.@.@@@@.....@.@.@@.@.@@@@@@@..@@@@@..@.@@@@@.@.@@@@..@.@@@..@.@@@.@@@@.@@..@@@@.@@.@..@@..@.@@@@@@@@@..@@..@.@@@.@@@@.@@@.@@@@@@@@.@@@@
@.@@@.@.@@..@@...@.@@@.@@@.@@.@.@.@@@@@.@.@@@@@@@@@@@@.@@...@.@.@.@.@...@@@....@.@@@.@@.@@@@@@@..@@.@...@...@.@@@@@@@..@@@.@@@..@@@@@@@@
@@.@.@.@@.@@@.@@@@@.@@.@.@@@@@@@.@@@@@@@.@@.@@@@@.@@@...@@.@@@@.@..@@.@@.@@@@.@@@.@@@.@.@@@@@@@@@..@@@@@@@.@@..@@@.@@.@@@.@@.@@.@@@@@@@@
@...@....@@@@..@.@..@.@..@@@@.@.@@...@.@@@@@.@.@...@@@@@@@@..@.@.@@.@@@.@@.@@@@..@@@.@@@@.@@@@@@@..@@@@.@.@@@@.@.@@@@@@.@@.@.@@.@@@.@@..
.@@@@...@@@@@@....@@@...@.@..@@@@@@@@@@.@.@@@@@..@@@..@...@..@@@.@@.@@@.@@@@..@@@.@@@.@@@@@@.@.@@.@@@.@.@@@@@@.@@@.@@@@@@.@@@@.@@@@.@@@@
@@@@..@@@.@.@..@...@.@@@...@..@....@@@..@@@@@@...@.@@@@@.@@@.@@@...@@@@@@.@.@@@..@@@@@..@@.@.@.@.@.@...@@..@.@...@@@@@.@@@..@@.@@.@@@@..
@@@@.@@@@.@@@.@@@@@@@@@@@@@@@@.@@@@@@@@.@@@.@@..@@@.@@.@@@@@@@@@@@@@.@@@...@......@@@..@@@.@..@@@@@@@.@..@@@@...@@@.@@@@@@@.@@@@@......@
.@@@@.@@@@@@@@.@@.@@@..@@.@@.@@..@..@...@.@@@@@@.@..@@.@.@@@.@@@.@@@@@@@@@@@..@@@..@@@@@@@..@@.@.@.@@@.@.@@.@@..@@@@@@@.@.@.@.@.@@@.@...
.@@.@@@@@@@.@@.@@@@@@..@@@@@.@@@.....@@@@@.@@.@@@@@@@@@@@@@@@@.@@@@@.......@@@@@.@@@@..@@....@@.@@@@@..@@.@@@@.@.@@....@@.@@.@..@@@@@@@.
...@.@@.@.@.@@@@@.@@@..@@@@@.@@@@@@@@@@.@@..@@@@@@@...@..@.@@@@.@@..@@@@@@@@@.@@@@@@@@@@.@.@.@@..@@@@.@..@.@@..@.@@@@@@@@@.@.@@@@@@.@@@@
@@.@@..@@.@.@....@.@...@@@@.@@@@@.@..@....@....@@..@@@@@..@...@..@..@@@...@@.@@..@...@@@...@@..@@@@@.@.@@..@.@@.....@@..@@@@......@@.@@.
@..@@@@@@@@.@.@.....@@.@@@@@@@@@@@.@@..@.@..@.@@@.@@@@@@@@@@@.@.@...@@.@@@@.@...@@@.@..@@@.@..@.@@..@@@.@@@...@@@@@.@@.@@..@.@@.@@@.@.@@
..@@..@.@.@.@..@@.@..@.@.@.@@.@@@@@.@@@@@@@@@@..@@@@@@...@@@@...@.@@.@@@@@.@@@@@.@@.@..@..@@@@@@....@@...@@@@...@@@..@.@..@@@.@@@.@@..@@
.@@@@..@@.@@@@@.@.@@.@@.@@@@@@@.@@@..@..@..@@@.@@@@..@@.@.@@@@@...@@.@@@@@.@@.@@@@@@..@@@@@.@.@.@@@@..@..@...@@@.@..@@@@@@@.@@@.@.@@.@.@
@@@@@@@@.@.@@.@@@.@@..@@@@..@..@@@@@@@.@@...@@@@@..@.@@@@@@.@@@@@@..@@..@@.@@.@@@@...@@.@@@...@@@.@..@@@@.@@@@.@@.@@@@@....@@@@@@.@@@@.@
@@@@@...@.@..@@@..@@@..@@@...@@..@.@@@@.@...@.@@@@.@@@...@..@@.@.@@@@@@@@@@..@@@@.@@@@@.@..@.@@@.@.@.@@.@..@@@@..@@..@@.@@@.@..@@@@@..@.
@@..@.@@@..@@@@..@.@@@@...@...@@@@.@@.@.@@.@@@@@.@@.@.@@@@@.@.@@@@.@@@@.@@.@@.@@@@@@.@.@@@..@.@@@.@@@@@@@@@@@@@@..@@@@@.@@@@@@.@@.@.@.@.
@@@@@.@@@@.@@@..@@.@@.@@@@...@@..@@@.@@@..@@.@..@.@@@.@.@@.@@@@@@.@@@@.@.@@@@@@@@.@@..@@@@@@@@@@..@@@@.@@@@@@@@@@@@@@.@@@.@@@@@...@.@.@@
..@@...@@@..@@@@..@@.@@.@@@@@....@.@.@@@@@@.@@@.@@.@.@@@.@@.@.@.@@@@@@.@@@.@@@@.@.@@@@@.@@...@@.@@...@@.@@..@@@@@@@..@.@.@@@..@@..@@@@.@
@.@@@@@@@@@@@@@@@.@..@@@@@.@@.@@@@.@.@.@..@@@@@@@.@@@.@.@@@@@..@@@@@@@@@@.@@@@@..@@@...@@.@.@.@.@@.@....@@@@@.@...@@.@@.@@@@...@@@.@..@@

1180
Inputs/Day5.txt Normal file

File diff suppressed because it is too large Load Diff

5
Inputs/Day6.txt Normal file
View File

@@ -0,0 +1,5 @@
2477 92 399 956 8 44 3 989 459 11 858 93 6 832 9 92 69 53 44 43 3 75 2 2 88 6 988 7 8 8171 71 1 6 2986 41 137 84 158 62 676 584 9765 49 723 33 1 38 65 96 53 181 541 29 781 5843 3636 278 57 719 619 9 79 82 227 3 68 3 43 76 3594 42 88 29 4 46 75 77 36 55 43 763 2588 775 86 949 48 5 59 2237 94 9 953 924 6 6 753 4 4 96 691 8 1 51 5174 6 196 1 744 52 35 45 84 2 45 515 325 3 2 31 859 17 569 747 3 6 117 83 9 52 7786 25 6278 7 168 61 3 647 75 817 74 5 34 1 15 691 42 75 33 45 54 5 914 78 47 98 876 5 685 52 25 7 6 758 463 4 39 544 25 62 7 145 374 899 78 8 54 1555 922 65 8736 6 1136 59 4749 187 69 97 469 3 698 844 26 3 23 92 32 7772 19 849 5774 77 46 98 65 39 686 1818 9 6489 217 835 78 629 149 2 6 47 571 9748 64 69 3 69 7 268 5 14 8 23 472 9 453 89 731 1 672 4 94 547 58 912 2793 56 35 261 7662 72 532 52 2 25 2 41 4 422 957 333 75 86 2 173 46 99 9436 78 34 433 267 26 324 246 5 144 243 234 91 7542 52 98 81 91 86 57 293 464 6931 5 594 8 96 23 3 166 77 99 453 73 469 98 2 342 74 8764 562 23 638 125 57 661 994 393 42 531 2 59 378 76 1 7 86 961 32 9 469 458 47 22 83 7 36 45 4 519 5128 74 11 15 38 2 497 59 1 54 3617 174 8323 7 73 4896 579 33 1 8 825 24 6622 95 69 35 26 84 463 16 6 92 6 644 387 79 41 4 4723 576 4 74 921 78 7 5134 447 741 61 3 92 469 2187 965 79 7 86 21 18 83 558 5 5792 294 26 86 3 6219 16 13 799 11 592 59 9375 526 97 14 6349 4 286 1 628 2 192 449 52 9 55 3761 221 9 3 124 1 1 59 75 15 922 1 561 3 13 91 66 85 315 68 8 59 58 87 137 7 226 27 19 926 527 9 45 619 73 72 812 12 449 16 172 45 925 7922 414 931 87 257 232 177 16 98 59 74 3 92 62 946 8 52 894 78 35 878 29 48 2642 82 98 91 59 79 76 2174 1628 1 61 63 981 6 33 193 494 6 78 92 46 54 83 9 36 7 923 59 644 7 68 6976 42 82 68 83 81 19 18 35 669 13 18 83 282 364 8 2 463 1471 21 687 3 4833 4797 37 379 3 67 65 52 75 777 1 5 43 24 583 54 15 68 75 351 6576 36 1 9951 42 25 267 94 81 13 214 6 828 538 78 5 92 229 92 32 9476 51 825 367 9 978 32 5 171 3867 48 179 634 617 5 96 978 4999 44 75 14 396 3 92 17 8865 23 644 75 79 91 161 343 35 273 96 46 48 83 19 346 141 269 75 516 19 894 155 95 8 421 86 62 91 86 4861 35 899 17 6 75 2 81 43 168 81 33 6664 36 78 63 491 9594 9987 722 435 879 48 267 56 68 92 33 15 86 17 946 74 876 667 8 729 829 72 93 256 56 552 99 238 927 384 142 9942 558 362 6 713 1 9 14 75 38 962 662 12 49 9736 68 8 71 923 85 31 546 62 49 82 31 37 33 61 566 42 733 4934 271 79 4 99 699 8 44 63 414 41 44 39 916 79 16 8 224 2 83 74 286 7 674 23 39 83 34 3 574 8285 112 8624 487 38 3 5 1 247 12 21 414 666 66 4 642 79 941 17 942 82 65 6165 9518 29 668 82 13 26 6492 445 5 63 25 494 357 8 17 6 47 32 1919 28 146 416 7 983 25 3538 67 11 85 3 21 129 37 67 58 733 1991 11 25 7 43 358 73 3244 872 67 145 5 1 32 2 49 4 769 1887 15 585 912 76 59 95 5 68 18 7 63 689 594 45 526 6 569 1 1 4 34 62 71 6478 4 81 2 68 7934 42 77 48 3219 596 414 992 983 331 8 68 29 249 6 86 247 257 81 97 7 587 4 58 512 129 55 5582 41 21 27 2 41 26 832 76 13 9763 928 91 495 78 5 176 396 97 64 35 99 89 21 4 7492 9 1 847 4 34 1529 2 28 6 44 983 36 88 3 3 5 921 144 3 273 52 34 435 4 9 48 54 5438 73 8121 345 2 27 36 57 538 46 19 75 9 7989 882 96 388 67 82 79 7 6 693 481 12 61 317 9 32 59 17 27 6 3292 9 7 5 15 8312 1 9 774 7 3 8 29 61 35 64 73 8977 733 37 88 6981 48 8 8 55 29 2 7 78 13 4373 74 54 4
3524 4 525 936 5 11 8 756 85 278 593 15 318 363 28 36 66 53 28 24 31 19 75 51 15 54 438 83 2 7698 68 8 5827 7972 11 942 67 5874 45 349 832 9364 3 744 64 19 22 53 5 33 4683 639 27 489 8517 8716 219 45 833 315 39 17 62 419 1 49 31 14 94 6865 62 69 63 4 48 77 81 33 13 789 545 4349 657 94 689 69 42 156 6321 863 96 263 3256 48 21 497 48 42 56 831 52 7 8936 6662 74 623 5 239 22 42 21 17 514 41 877 231 79 56 74 975 53 681 5769 6 93 962 917 9 76 7181 75 7626 27 498 272 48 571 93 883 786 8 72 5 52 692 12 25 59 37 57 71 785 97 81 54 152 54 358 47 97 39 939 619 449 48 18 262 865 18 57 578 695 178 68 47 35 729 397 62 4373 9 4865 599 6275 756 76 91 798 8 272 647 76 48 47 64 29 5815 855 12 8982 66 28 13 6 1 525 9547 49 5782 243 291 557 148 24 1 1 32 242 8593 39 165 63 236 294 973 51 62 64 76 268 55 573 26 936 11 344 29 42 114 56 318 1236 816 59 193 7522 68 617 22 62 51 27 78 98 345 137 333 57 19 53 833 59 11 7893 424 55 792 168 86 759 538 91 681 791 639 88 722 32 34 99 71 99 97 518 775 4816 3 726 6 17 37 728 453 67 353 846 55 936 6 439 546 42 3252 664 19 453 57 91 329 629 646 2 1523 494 82 386 363 89 9 561 67 248 41 248 742 18 83 66 82 31 24 16 824 345 58 255 62 16 11 671 83 3 75 8843 538 2398 1 92 8284 68 99 235 1 117 65 4614 254 52 25 65 16 649 86 52 62 96 183 815 81 88 28 1154 641 51 13 454 74 6 1655 329 4994 13 11 6918 871 1446 499 18 92 42 23 89 38 172 8 6774 875 33 19 25 8339 72 73 774 38 8426 41 1162 87 38 53 3822 25 927 58 567 55 225 298 81 25 33 6243 575 52 9 714 7 74 74 22 53 142 7 275 5 72 94 21 52 498 89 5 99 23 24 177 5 889 28 11 687 777 31 35 983 39 45 578 81 924 29 557 85 149 6725 868 158 54 277 78 259 84 79 22 832 43 45 93 818 3 46 688 81 72 962 57 49 585 45 33 78 35 92 55 7254 9999 7 5758 15 599 9 84 921 784 61 23 39 188 72 86 7 87 394 3729 726 472 3 59 6657 96 234 84 21 425 46 37 61 561 857 82 5961 7837 619 5 24 996 9647 47 224 9 2828 4863 83 189 11 5 67 83 99 765 58 21 171 69 498 18 786 711 174 221 9588 27 57 6556 756 75 387 72 35 133 758 86 641 723 245 1 95 116 61 69 535 71 646 878 48 111 44 76 213 9698 125 543 316 882 8 53 212 5191 14 32 79 78 925 11 75 9226 13 639 65 65 913 448 114 2224 754 262 63 23 27 25 32 135 574 29 1295 28 844 441 54 473 789 57 65 88 76 8335 9124 5163 718 5 42 62 29 41 481 11 623 3458 66 47 38 194 2492 4658 558 362 3914 61 372 82 17 62 6 752 768 821 2731 1 993 164 54 687 221 89 55 292 1 291 252 371 564 814 582 131 938 786 833 781 6 2 21 611 55 927 556 43 559 6367 29 629 22 295 78 51 8697 8 38 54 42 57 852 947 93 57 376 3884 812 531 479 99 687 75 23 53 558 93 314 74 396 62 85 996 93 37 57 59 187 5 868 91 97 226 48 87 113 2366 962 3969 565 921 91 55 3 423 78 48 41 84 81 997 948 83 957 82 5721 78 19 9556 8782 52 728 48 85 31 9827 964 679 72 8 46 336 7 18 8 612 13 44 135 753 624 88 145 66 9781 31 97 15 6 94 85 52 61 86 881 1697 43 28 8 35 664 27 7275 339 18 713 181 735 39 894 26 43 794 8772 49 861 69 54 574 38 547 547 45 64 26 822 783 89 492 4 2297 7 38 36 97 33 91 3312 73 57 98 38 4598 33 21 65 8971 2793 538 169 827 966 5 871 91 514 4 13 9839 918 62 32 97 648 12 31 8 678 9 2872 35 259 26 976 565 97 644 72 91 6271 571 9317 734 39 74 778 498 24 75 57 95 11 43 4 7566 4 639 936 76 38 5512 3999 94 4 294 792 51 64 899 64 7 836 857 46 842 559 898 352 46 85 87 31 6861 76 4421 947 91 62 92 776 633 42 82 884 76 9929 79 84 398 9 71 81 89 59 838 944 393 54 326 6 21 79 571 284 68 4797 3 97 5 85 3634 1 675 482 25 4 57 57 44 38 59 11 8745 263 85 672 8866 46 572 192 81 54 9 25 8996 78 3141 76 91 37
6243 4 595 999 5 61 389 48 35 289 956 63 563 77 84 57 7 22 75 941 56 46 61 64 91 442 318 57 45 1474 71 697 2699 1527 62 151 69 7235 94 161 698 6125 9 513 33 86 28 18 1 58 2346 622 54 826 767 6511 732 4 357 1987 78 112 1 799 6 9 12 13 79 9383 816 21 14 33 385 35 44 5 51 791 118 377 886 7 55 93 343 912 49 694 89 648 3334 71 338 546 66 721 98 986 56 88 7824 6928 22 892 33 549 8 62 9 11 326 66 595 27 39 43 15 89 61 254 2272 83 58 5467 1419 12 66 581 23 394 94 473 636 211 239 82 993 752 56 41 737 23 51 16 15 36 93 253 599 64 93 38 36 958 93 439 83 93 27 6434 569 42 85 49 51 237 32 95 894 753 265 76 74 918 245 516 29 19 9 1897 277 724 247 78 93 121 89 87 872 66 75 48 56 82 9358 567 65 3414 771 969 66 7 2 968 223 18 8492 257 789 986 7753 49 529 4 852 282 696 24 972 63 5189 351 12 596 5 877 52 751 757 385 96 66 544 685 35 66 831 31 422 9237 913 27 441 3594 95 765 99 35 67 611 22 97 79 821 251 934 617 917 248 91 29 3667 293 4 776 874 21 234 47 39 136 538 8 74 294 59 27 71 68 98 52 2 172 625 95 1352 44 47 67 311 986 22 748 855 58 163 1 6116 986 94 1449 223 35 452 82 41 85 725 74 4 8719 2177 66 655 329 62 8 924 66 413 324 182 956 6 44 54 244 71 491 64 376 217 96 977 85 71 45 185 64 79 1 751 922 2697 76 93 9675 22 56 711 85 724 93 151 771 9 55 11 897 832 63 982 27 46 976 622 82 842 972 2292 546 44 53 347 25 53 6122 199 3665 77 48 9248 155 1416 396 41 65 97 2 52 79 478 81 734 958 284 14 436 8783 38 58 723 82 8164 12 6122 92 82 87 1963 91 415 75 35 52 635 894 55 76 315 5868 988 99 72 991 83 612 99 76 39 429 269 91 86 56 68 56 69 923 4 94 44 39 3 963 25 33 91 43 53 389 65 4 421 8 9 194 36 687 24 516 87 347 657 23 99 86 397 44 691 55 66 24 781 14 37 91 576 197 32 856 43 34 694 53 79 169 48 76 88 3 67 24 672 8537 132 4486 27 925 575 33 948 793 164 96 51 266 18 68 829 6 114 4438 176 5 16 32 81 93 751 58 67 7663 61 5 153 38 938 73 3387 4737 814 68 19 654 76 84 461 9 1438 652 25 364 69 3 75 2 35 784 32 891 271 48 611 55 874 596 721 388 7995 94 386 8146 741 5 499 51 26 498 255 78 1587 262 152 77 28 347 99 18 754 71 83 753 67 24 46 263 59 9758 326 799 213 611 492 691 993 669 28 81 1 34 9976 71 3 1472 28 787 63 998 897 867 86 3867 437 9776 75 53 57 83 47 841 81 41 8854 72 734 628 15 949 275 2 97 91 45 31 1713 3573 722 29 913 34 68 9 159 79 557 589 4 63 67 137 325 2452 7 99 7318 66 39 68 69 67 6 315 772 117 1594 2 197 984 182 695 741 538 86 526 8 637 419 486 772 354 199 11 471 8 8789 92 16 368 35 479 92 355 236 25 588 5914 583 144 6 452 6 8 5849 2 73 64 53 29 741 2754 66 1 497 818 559 913 885 53 191 43 272 89 975 11 2156 97 682 74 32 759 1 37 96 82 995 6 696 866 41 681 55 3227 34 8466 743 221 27 164 51 16 6 91 512 38 5 61 71 789 4858 837 772 58 1999 75 8 8891 6 667 99 5 89 29 9769 717 254 45 3 88 749 84 22 36 327 46 2 887 5914 473 41 33 42 348 682 41 24 16 17 51 47 47 19 2797 798 54 2 94 19 97 78 6427 383 1251 38 887 263 42 111 15 87 929 2439 9 171 82 66 138 27 687 431 18 13 574 749 816 66 285 16 9695 56 79 53 6 93 4624 824 79 26 76 68 147 86 69 42 844 9751 1961 64 3743 28 7 151 4 563 23 9 6196 624 212 81 94 84 86 92 9 174 4 7889 75 121 8 521 666 2 68 49 9 261 211 5289 86 74 96 462 757 26 4 597 9 33 119 62 784 4 4252 933 92 54 8423 9562 32 74 425 42 18 13 535 559 43 149 858 83 525 951 944 775 641 87 664 23 4543 64 9193 459 69 49 381 158 24 53 52 172 512 1841 66 89 26 3 4 853 18 63 914 537 589 6 85 5 41 47 434 351 531 461 48 76 1 3 2789 11 276 637 92 17 43 53 494 83 42 3 477 44 98 2948 277 66 9569 816 26 57 34 794 9725 51 858 15 828 17
44 4 677 9 75 13 526 28 68 189 537 572 232 3 23 31 8 71 23 719 15 161 21 94 18 648 939 791 53 9839 46 954 4137 835 28 67 6 4633 24 348 217 136 2 378 28 57 55 96 3 17 9319 879 4 266 541 1633 6 9 142 9496 18 524 2 17 54 8 51 4 55 753 463 85 89 43 758 94 9 2 77 232 374 498 946 9 7 5 234 561 23 212 1225 413 5363 93 1275 112 21 515 91 86 73 388 5887 57 54 32 69 298 2 84 3 78 272 28 44 79 46 11 62 34 57 892 5485 27 52 4894 5922 694 59 376 23 5 18 28 262 153 813 28 38 212 96 1 348 32 2 63 26 79 23 621 192 57 89 87 88 2781 51 84 8 49 17 5145 57 75 82 3 22 689 97 71 488 39 2 9 49 486 732 7331 937 65 13 558 126 6 68 91 92 942 346 2 145 94 653 91 96 11 9495 763 3 758 756 363 2 3 1 119 65 43 165 48 13 5993 4351 2 895 68 412 1 581 496 517 29 4451 236 39 736 8 623 2 253 928 8 92 5 379 511 69 25 674 59 733 257 452 2 63 668 1 418 85 37 12 772 62 82 9 93 5 5682 457 813 827 31 56 4 478 7 91 2 59 862 9 18 737 56 6 28 2 93 69 62 26 48 31 6 138 77 99 5487 13 27 28 467 65 96 867 82 42 929 4 4216 98 43 1685 49 45 13 9 85 49 79 51 2 7321 6454 13 148 396 54 28 648 27 452 445 1397 518 6 57 9 296 5 367 32 77 22 89 273 41 31 88 416 91 46 2 13 2 856 18 472 122 96 1544 788 75 837 53 1 598 5 84 78 728 29 81 593 8 99 949 762 91 868 273 18 51 234 23 51 83 51 386 1 6372 47 32 7821 63 39 868 95 77 7 1 9 924 653 91 439 163 442 2 441 4828 59 6 113 99 6543 46 674 71 9 59 2 75 356 259 2 11 3737 938 61 828 983 988 16 84 37 742 51 243 266 3 99 386 626 47 47 41 49 6 71 75 3 982 77 77 6 213 47 13 4 16 13 442 21 6 875 7 1 2 58 233 59 586 35 79 1 52 6 57 34 64 37 17 12 81 622 14 76 17 31 254 9 379 68 58 55 24 3 88 15 2 54 8 5 26 623 7 396 6156 92 664 473 56 83 165 218 1 4 776 25 87 278 6 844 4416 924 1 48 2 3 28 866 28 5 4248 88 1 756 99 636 26 2438 1483 11 54 979 72 59 17 121 13 94 48 52 256 37 2 14 6 3 118 69 2839 721 61 682 75 982 514 531 69 4178 8 255 9521 234 9 36 882 36 173 982 76 3564 737 762 11 69 66 332 52 175 63 9 556 64 87 44 5488 9 424 895 864 7 262 986 4665 8 964 21 15 5 75 5275 85 5 691 75 47 87 282 869 14 2 5566 768 4994 957 1 24 82 5 78 8 3 5628 89 216 1 36 987 99 9 65 59 89 5 7342 1876 832 63 997 19 72 5 82 12 685 4 2 17 1 27 63 7676 2 23 9748 75 74 46 42 97 7 2581 438 731 5298 2 5 448 582 315 677 425 88 912 4 829 485 1 54 37 47 1 854 2 6817 83 38 733 66 654 5 33 213 18 5471 749 398 956 3 413 5 2 6372 3 76 61 461 18 678 3947 9 6 17 784 73 742 584 48 98 62 371 7 8 73 3475 83 857 3 8 266 7 98 96 64 27 69 876 772 4 535 3 6662 3 824 487 586 97 961 17 36 63 12 761 94 1 6 8 8459 5463 877 561 17 1295 67 2 25 4 959 1 6 39 5 837 61 439 22 7 9 4 84 2 96 617 362 4 447 2422 715 26 1 43 792 482 6 5 96 52 49 82 9 15 9332 42 57 1 82 7 6 39 828 47 2865 33 514 371 14 871 63 41 1 87 7 442 66 54 863 471 225 668 23 17 777 16 27 35 6 771 4416 48 94 19 6 19 7595 9 38 47 62 45 61 4 42 572 66 9496 3978 6 8437 87 89 874 6 354 58 6 6218 543 719 64 95 3 22 18 7 77 9 48 6 934 7 918 139 5 7 84 2 1 39 2633 86 9 39 378 624 53 4 378 5 99 1252 62 654 65 7241 81 63 6 744 3881 9 81 342 23 33 79 978 779 62 69 769 56 988 673 938 964 333 72 655 64 52 13 9738 16 711 5 641 476 68 3 92 594 832 99 58 56 31 7 1 232 29 15 151 26 199 8 8 49 65 9 498 712 485 555 82 88 58 6 5747 35 257 668 84 27 91 4 832 69 36 2 462 4 81 1656 19 3 1118 694 93 52 288 456 3738 63 78 974 968 34
+ * * * * * + + + * + * + + * + * + + * * + * * * * * + + + * * + + + + * + + * * + * * * + * * + * + * + * + + * * + + * * * * * + + + * + * * * * + * + + * + + + + * + + * + + * + * + * + + * * + + * * + + + + + * * * * + * * * * * + + * * * + * * + + * * + * + * + * * * * * + + + * * + + * * * + * + * + + + * + * * * + + + * * * + * + * * * * * + + + + + * + * + * * * + * + * * * * + * + * + + * * + * * + + * + * * + + * + * + + + + + + + * + * * + * * + + * * * * + + * * * + + * * + * * + * + * * + * + * + + + * + * + * + + * + + + * + * * * + * + + * + * * + + + + + * * * + * + * + + * + * * + * + + * + + + * + + + * + + * * + * + + + * * + * * * * + + + + * + * + * * * * + + + + + + + + + + * + + * + + * + * * * * + + + * + + + + * * * * + + + + * * + * + * * * + * + + * * + + * + * + * + + * + + + + * * + + * + + + + * + + * + * + * * * * + + * + + * + * * + + + + + + + * + + * * * + * + * + + * * + + * + + * + + * * + + * + * + * + + + * * + + + + + + + + * * + * * + + + + + * + * + * + + * * * * + * + * + * * + * + * * + + + * + + * + * + + * * * * + * * * + + * * * + + + + * * + + * * * + + + * + + * + + * * + + * + * + * + * + * + * + + * * + * + + * + * * * * * + + + * + * + + * * + * + + + * * * + + + * * * + * + * + + + + * * * * + + + + + + + + + * * + + + + + + * + * * + + * * + + + + + + + + + * + + + + * + * + * + + * * * + + * + + * + * + * * * * * + + + + * * * * * * + * * * * + + + * * * + + * * + + * * * + + + + + * * * * * * + + * + + * * * + + + + + * * * * + * * * * * + + + * * * + * + + + + + * + + + * * + + * * + + + + * + * + + * * * + + + * + * + + + * + + * * * * * + + * + * * + + * + * + + * + + * * + * * + * + + * * * * + + + + * * + + * * * * + * * * + + + * + + * * * * * * + + + + + + + + + * * + * + + + + + * * * + * + * * * * * + + + * * + * + * + + + + + + * + * * * + * * * * + * + + + * * + * * + + + * * + * * + + * * * + + * * * * + * * + + + * * + + * + + * + + * + * + * + * * * * * + * * + + + * + + * + * * + + + + + + * * *

142
Inputs/Day7.txt Normal file
View File

@@ -0,0 +1,142 @@
......................................................................S......................................................................
.............................................................................................................................................
......................................................................^......................................................................
.............................................................................................................................................
.....................................................................^.^.....................................................................
.............................................................................................................................................
....................................................................^...^....................................................................
.............................................................................................................................................
...................................................................^.^...^...................................................................
.............................................................................................................................................
..................................................................^.^...^.^..................................................................
.............................................................................................................................................
.................................................................^...^...^.^.................................................................
.............................................................................................................................................
................................................................^.^.^.^...^.^................................................................
.............................................................................................................................................
...............................................................^...^.^.^.^.^.^...............................................................
.............................................................................................................................................
..............................................................^.^.^...^.^...^.^..............................................................
.............................................................................................................................................
.............................................................^.^.^.^.^.^.^.^.^.^.............................................................
.............................................................................................................................................
............................................................^...^...........^...^............................................................
.............................................................................................................................................
...........................................................^.^...^.^.^.^.^.^...^.^...........................................................
.............................................................................................................................................
..........................................................^.^.^.^.^...^.^.^.^...^.^..........................................................
.............................................................................................................................................
.........................................................^...^...^.^.^.^.^...^.^.^.^.........................................................
.............................................................................................................................................
........................................................^.^.^...^.^.^.......^.^...^.^........................................................
.............................................................................................................................................
.......................................................^.^.^.^.^.^.......^.^.^.......^.......................................................
.............................................................................................................................................
......................................................^.^.^.^.^.^...^.^.^.^.^...^.....^......................................................
.............................................................................................................................................
.....................................................^.....^.^.^.....^.^.^.^.^.......^.^.....................................................
.............................................................................................................................................
....................................................^.^.....^.^.^.^.^.^.^.^.....^.^...^.^....................................................
.............................................................................................................................................
...................................................^.^.....^.^.^...^...^.^.^.^.^...^.^.^.^...................................................
.............................................................................................................................................
..................................................^.^.^.....^.^...^.^.^.........^.^.^.^.^.^..................................................
.............................................................................................................................................
.................................................^...^...^.....^...^.^.^.^.^.....^.^.^.^.^.^.................................................
.............................................................................................................................................
................................................^.^.^.^.^...^.^.^.^.^.^.^.^...^.....^.^.^.^.^................................................
.............................................................................................................................................
...............................................^...^...^.^.......^...^.^.^.^.^.^.....^.^.....^...............................................
.............................................................................................................................................
..............................................^.^.....^.^.^.....^.^.^.....^.....^.^.......^.^.^..............................................
.............................................................................................................................................
.............................................^.^.^.^...^.......^...^.^.^...^.^.......^.^.^...^.^.............................................
.............................................................................................................................................
............................................^.....^...^.^.^...^.^...^.^...^.^...^.^.^.^.^.^.^.^.^............................................
.............................................................................................................................................
...........................................^.^...^.^.^...^.^...^.^.^.^...^...^.^.^.^.^...^.^.....^...........................................
.............................................................................................................................................
..........................................^...^.^.....^.^.......^...^...^...^.......^...^.^.......^..........................................
.............................................................................................................................................
.........................................^.......^...^.^.^.....^.^.^.^...^.^...^.^...^.^.^.^.^.^...^.........................................
.............................................................................................................................................
........................................^.^.^.^...^.^.^.^.^.....^...^...^.^.....^...^.^.^.^...^.^...^........................................
.............................................................................................................................................
.......................................^.^.^.^.^.^.......^.^.^...^.......^.^.^...^.^.^.^...^.^.....^.^.......................................
.............................................................................................................................................
......................................^...^.....^.^...^.........^.^.^...^.^.^.^.^...^...^.....^.^.^.^.^......................................
.............................................................................................................................................
.....................................^...^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.....^.^.^.^...^...^.^.^.....^.....................................
.............................................................................................................................................
....................................^.^.^.^.^.^.......^.^.^.^.....^.^.^.^.^.^.....^.^.....^.^.^.^...^.^.^....................................
.............................................................................................................................................
...................................^...^.^.^.^...^...^.^.........^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.....^...................................
.............................................................................................................................................
..................................^.^...^.^.^.^.^...^...^.^.^.........^.^.^.^.^.^...^.^.^.^.^.^.....^.^.^.^..................................
.............................................................................................................................................
.................................^.^.....^...^.^.^.^...^...^.^.^.^.^.^...^.^.^.^.....^.^...^.^.^...^.^.^...^.................................
.............................................................................................................................................
................................^.^.^.^.^.^.....^.^...^...^.^.^.^.^.^...^.^...^.^...^.^.^.^...^.^.^.^.^.^...^................................
.............................................................................................................................................
...............................^...^...^...^.^.^.^.^...^.^.^...^.^...^.^.^.^.....^...^.^...^.......^.......^.^...............................
.............................................................................................................................................
..............................^.^.^.....^...^.^.^.^.^.^.^.^.^.^.^...^.......^...^.^.^.^.^...^.......^.^.^.^.^.^..............................
.............................................................................................................................................
.............................^.^.^.....^.^.^.^.....^.^.^.^.^.^.^.^.^.^.^.^.^.^...^...^.^...^...^.^.....^...^...^.............................
.............................................................................................................................................
............................^.^...^.^.^.^.^.^.^.^...^.^...^.....^.^.^.^.^...^.^.^.^...^...^.^.^.^.^.^.^...^...^.^............................
.............................................................................................................................................
...........................^.^...^.^.....^...^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^...^...^.....^.^.^...^...^.^.^.^.^.^...........................
.............................................................................................................................................
..........................^.^.^.^.^.^.^...^.^.^.^...^.^.......^.^...^.^...^...^.....^.^.^...^.....^...^.^.^.^.^.^.^..........................
.............................................................................................................................................
.........................^.^.^.^.^.^.^.....^...^.^.^.^.^.^...^.^.^.^.^.^...^.........^.....^.^.^.^.^...^...^.....^.^.........................
.............................................................................................................................................
........................^...^.^...^.^.^.^.^.^.^...^.^.^.^.^.....^.^.^.^.^.^.^.....^...^.^.^.^.^.^...^.^.^.^...^...^.^........................
.............................................................................................................................................
.......................^.^.^.^.^...^...^.^...^.^.^.^.^.^...^...^.^...^.^.^.^.........^.^.^.^.....^.^.^.^.^...^.^...^.^.......................
.............................................................................................................................................
......................^.^.^.^.^.^.^.^.....^.....^.^.^.^.^.^.^.^.^.^.....^.^.^...^...^.^.^.^.....^.^.^.....^.^.^...^.^.^......................
.............................................................................................................................................
.....................^.^...^...^.^.^.^.^.^.^...^.^...^...^.^...^.^...^.....^.^.^.....^.^.^...^.^.^.^.^.^.^.^.^...^...^.^.....................
.............................................................................................................................................
....................^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.^...^.^.^.^...^.^.^.^.^...^.^.^...^.^.^...^...^.^.^.......^.^.^...^....................
.............................................................................................................................................
...................^...^...^.^.^.^.^...^.^.^.^.....^.^.^...^.....^.^.^.^...^.^...^.^...^...^.^.^.^...^.^.^.^.^.^.^...^.^.^...................
.............................................................................................................................................
..................^...^.^...^.^.^...^.^...^.^.^...^.^.^...........^...^.^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.....^.^.^.^.^.^.^.^..................
.............................................................................................................................................
.................^.^.....^.^.^...^.^...^.^.^...^...^.^...^.^.^...^.....^.^.^.^.^.^.^...^...^...^...^.^...^.^.^.^.^.^...^...^.................
.............................................................................................................................................
................^.^.^...^.^.^.^.^.^.^.^...^.^...^.^...^.^.^.^.^.^.^.^.^.^.^...^...^.^.^.^.^.^.^.^.^...^.^.^.^...^.^.^.^.^.^.^................
.............................................................................................................................................
...............^.^.^.^.......^.^.^.^...^.^.^.^.^...^...^.......^.^.^.^.^.^.^.^.^...^.^.^.....^.^.^...^.....^.^.^...^...^.^...^...............
.............................................................................................................................................
..............^...^.^...^.^...^.^.^...^.^.^...^...^.^...^...^.........^.^.^.^.^...^...^.^...^.^...^.^.^...^...^.^.....^.^...^.^..............
.............................................................................................................................................
.............^.......^.....^...^.^.^.^.^.....^...^...^.^.^.^.^.^...^.......^.^.^.....^.^.^.^.^.^.^.^.....^.^...^...^.^.^...^.^.^.............
.............................................................................................................................................
............^.^...^...^.......^.....^...^.^.^...^.^.^.^.^.^.^.....^...^.^.....^.^.^.^.^.^.^...^...^.^.....^.^.^.^.^.^.^.^.^.^.^.^............
.............................................................................................................................................
...........^.^...^.....^...^...^.^.^.^.^.^.^...^...^.....^.^.^.^.^...^...^.^.^.^.^...^.^.^...^.^.....^...^.......^...^...^.^...^.^...........
.............................................................................................................................................
..........^...^...^.^...^.^.^...........^...^...^.^.^.^.^.^...^.^.^...^...^.^...^.^.^.^.^.^...^.^.^.^.^.^.^...^.^.....^.^.^.^.^.^.^..........
.............................................................................................................................................
.........^.^.^.....^.....^.^.^.^.^.^...^...^...^.^...^...^.^.^.^.^...^.^.^.^...^...^.^.^.^.^.^...^.....^.....^.^.^.^.^.^.^.^...^...^.........
.............................................................................................................................................
........^.^.^...^.^...^.^.^.^.^.^.^.^.^.^...^.^...^.....^.^.......^.^.......^...^...^.^.^.^.^.^.^...^...^.^.^.^...^.^.^.^.^.^.^.^...^........
.............................................................................................................................................
.......^...^.^.^.^.^.^...^...^.^...^.....^...^...^...^.^.........^.^.^.^.^.^.^.^.^.^...^...^.^.^...^.^...^.^.^.^...^.^...^.^.^...^.^.^.......
.............................................................................................................................................
......^.^.......^.^.^...^.^.^.^...^.^.^.^.^.^...^.^.....^.^.^.......^.^.^.^.^.....^.^...^.^.^.^.^.....^.^.^.^.^.^.^.....^...^...^.^.^.^......
.............................................................................................................................................
.....^...^.^.^.....^.^...^...^.....^.^...^.^...^.^.^...^.....^.^.^...^.^.^.^.^.^...^.^.^.......^.^.....^.^.^.........^...^.^.^.^.^.^.^.^.....
.............................................................................................................................................
....^.^...^.....^.^.....^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.....^...^.^...^.^...^...^...^.^.^.^.^.^.^.^.^.^...^.^.^...^.^...^.^.^...^.^...^....
.............................................................................................................................................
...^.^.^.^.^...^...^.^.^.^.....^...^.^.^.^.....^...^.....^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^...^.^.^.^.^.^.^...^.^.......^.....^...^.^...
.............................................................................................................................................
..^...^.^...^.^...^.^.^.^.^...^...^.^.^.....^.^.^.^...^.^.^...^.^...^.^.^.^.^.^.....^.^.^.^.^.^.^.^.^...^...^...^...^.^.......^.^.^.^.^.^.^..
.............................................................................................................................................
.^.^...^.^.....^...^.^.^.^...^.^.^...^...^.^.^.^.^.....^...^...^.^...^.^...^.^...^.^...^.^.^.^.^.^.....^.^.^.^.^.^.^.^...^.^.^.^.^...^.^.^.^.
.............................................................................................................................................

1000
Inputs/Day8.txt Normal file

File diff suppressed because it is too large Load Diff

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;
}
}