From f1cfe9d6146bb6acf135183d637e995e80afaeb8 Mon Sep 17 00:00:00 2001
From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com>
Date: Sat, 16 Dec 2023 20:39:06 -0600
Subject: [PATCH] chore: add xml comments
---
11/CosmicExpansion/Program.cs | 52 +++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/11/CosmicExpansion/Program.cs b/11/CosmicExpansion/Program.cs
index 137ec62..424c97a 100644
--- a/11/CosmicExpansion/Program.cs
+++ b/11/CosmicExpansion/Program.cs
@@ -38,6 +38,13 @@ public class Program
}
}
+///
+/// Represents the universe.
+///
+/// The height of the universe.
+/// The width of the universe.
+/// The galaxies in the universe.
+/// An instance of .
public class Universe(
int height,
int width,
@@ -45,14 +52,34 @@ public class Universe(
)
{
private const char GalaxySymbol = '#';
+
+ ///
+ /// Gets the height of the universe.
+ ///
public int Height { get; init; } = height;
+
+ ///
+ /// Gets the width of the universe.
+ ///
public int Width { get; init; } = width;
+
+ ///
+ /// Gets the galaxies in the universe.
+ ///
public List Galaxies { get; init; } = galaxies;
+
+ ///
+ /// Gets the sum of the shortest paths between galaxies.
+ ///
public long SumOfShortestPathsBetweenGalaxies =>
GetShortestPathsBetweenGalaxies()
.Values
.Sum();
+ ///
+ /// Gets the shortest paths between all pairs of galaxies.
+ ///
+ /// A dictionary containing the shortest paths between galaxies.
public Dictionary<(int galaxyOneIndex, int galaxyTwoIndex), long> GetShortestPathsBetweenGalaxies()
{
var shortestPaths = new Dictionary<(int galaxyOneIndex, int galaxyTwoIndex), long>();
@@ -78,9 +105,21 @@ public class Universe(
return shortestPaths;
}
+ ///
+ /// Calculates the distance between two galaxies.
+ ///
+ /// The first galaxy.
+ /// The second galaxy.
+ /// The distance between the two galaxies.
public static long CalculateDistanceBetweenGalaxies(Galaxy galaxyOne, Galaxy galaxyTwo) =>
Math.Abs(galaxyTwo.Row - galaxyOne.Row) + Math.Abs(galaxyTwo.Column - galaxyOne.Column);
+ ///
+ /// Parses the input into an instance of .
+ ///
+ /// The input.
+ /// The factor by which to expand the universe.
+ /// An instance of .
public static Universe Parse(string[] input, int expandFactor = 2)
{
var emptyRows = new List();
@@ -161,11 +200,24 @@ public class Universe(
}
}
+///
+/// Represents a galaxy.
+///
+/// The row of the galaxy.
+/// The column of the galaxy.
+/// An instance of .
public class Galaxy(
long row,
long column
)
{
+ ///
+ /// Gets the row of the galaxy.
+ ///
public long Row { get; init; } = row;
+
+ ///
+ /// Gets the column of the galaxy.
+ ///
public long Column { get; init; } = column;
}
\ No newline at end of file