|
|
@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
using AdventOfCode.Models;
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace AdventOfCode._2023
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public class Day11 : AOCDay
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override AOCResponse ExecutePartA()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this._response;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override AOCResponse ExecutePartB()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this._response;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UniverseGalaxy
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
private string[,] _board;
|
|
|
|
|
|
|
|
public UniverseGalaxy(List<string> input)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var rows = input.Count;
|
|
|
|
|
|
|
|
var columns = input.First().Length;
|
|
|
|
|
|
|
|
_board = new string[rows, columns];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int y = 0; y < rows; y++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int x = 0; x < columns; x++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_board[x, y] = input[x][y].ToString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO Double the board
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO Find all the galaxies on the board
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO Calculate the distance between all of the galaxies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO Find the shortest distance between them!
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Galaxy
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
public Dictionary<string, long> DistanceLookup { get; set; }
|
|
|
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
public int X { get; set; }
|
|
|
|
|
|
|
|
public int Y { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void CalculateDistance(IEnumerable<Galaxy> galaxies)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DistanceLookup = new Dictionary<string, long>();
|
|
|
|
|
|
|
|
foreach (var galaxy in galaxies)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (galaxy.Id.Equals(this.Id)) continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long distanceBetweenGalaxies = -1; //TODO need to calculate this? some math.min and math.max
|
|
|
|
|
|
|
|
DistanceLookup[galaxy.Id] = distanceBetweenGalaxies;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|