-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
38 lines (28 loc) · 976 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using AdventOfCode._2021_15;
using AdventOfCode.Common;
var map = Resources.GetInputFileLines().ParseAsJaggedArray(c => c - '0');
static int[][] Resize(int[][] map, int factor)
{
int sizeY = map.Length;
int sizeX = map[0].Length;
var resizedMap = new int[sizeY * factor][];
for (int y = 0; y < sizeY * factor; y++)
{
resizedMap[y] = new int[sizeX * factor];
for (int x = 0; x < sizeX * factor; x++)
{
int original = map[y % sizeY][x % sizeX];
int increase = (x / sizeY) + (y / sizeX);
resizedMap[y][x] = original + increase;
while (resizedMap[y][x] > 9)
{
resizedMap[y][x] -= 9;
}
}
}
return resizedMap;
}
var pathFinder = new PathFinder(map);
Console.WriteLine($"Part 1: {pathFinder.FindShortestPath()}");
pathFinder = new PathFinder(Resize(map, 5));
Console.WriteLine($"Part 2: {pathFinder.FindShortestPath()}");