aboutsummaryrefslogtreecommitdiffstats
path: root/src/Program/Program.cs
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2021-10-07 00:32:45 -0500
committerToby Vincent <tobyv13@gmail.com>2021-10-07 00:32:45 -0500
commit738ccef61886c1fded9797cbfbc4a88fcffbd624 (patch)
tree185e4a630efb4741ecd085ea5562dc6ecbbb18d6 /src/Program/Program.cs
parent2ef857e04703e720706a1e7cd95b325c8ee54f97 (diff)
Implemented everything. Need a beer.
Co-authored-by: nkollack <nkollack@gmail.com>
Diffstat (limited to 'src/Program/Program.cs')
-rw-r--r--src/Program/Program.cs33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/Program/Program.cs b/src/Program/Program.cs
index 6fddc77..9ba697b 100644
--- a/src/Program/Program.cs
+++ b/src/Program/Program.cs
@@ -1,2 +1,33 @@
-// See https://aka.ms/new-console-template for more information
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+namespace ClosestPair
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ FileInfo inputFile = (args.Length > 0) ? new FileInfo(args[0]) : new FileInfo("points1.txt");
+
+ if (!inputFile.Exists) {
+ Console.WriteLine($"Failed to open {inputFile}: File does not exist.");
+ return;
+ }
+
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+
+ PointArray points = new PointArray(inputFile.FullName);
+ PointPair closestPair = ClosestPair.FindClosestPair(points);
+
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+
+ Console.WriteLine($"Closest Points: {closestPair}");
+ Console.WriteLine($"Runtime: {ts.ToString("mm\\:ss\\.ff")}");
+ }
+ }
+
+} \ No newline at end of file