about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.drone.yml3
-rw-r--r--Day12.cs3
-rw-r--r--Day14.cs15
3 files changed, 13 insertions, 8 deletions
diff --git a/.drone.yml b/.drone.yml
index 9debcdf..42c62bb 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -4,7 +4,6 @@ name: run
 
 steps:
     - name: run
-      image: mcr.microsoft.com/dotnet/core/sdk:latest
+      image: mcr.microsoft.com/dotnet/sdk:latest
       commands:
           - dotnet run
-
diff --git a/Day12.cs b/Day12.cs
index b04426d..4d6178a 100644
--- a/Day12.cs
+++ b/Day12.cs
@@ -6,9 +6,8 @@ namespace aoc2019
 {
     internal sealed class Day12 : Day
     {
-        private readonly List<Position> startingPositions;
-
         private readonly List<Position> moons;
+        private readonly List<Position> startingPositions;
         private int step;
 
         public Day12()
diff --git a/Day14.cs b/Day14.cs
index e4c46e8..1aff2bf 100644
--- a/Day14.cs
+++ b/Day14.cs
@@ -22,7 +22,7 @@ namespace aoc2019
         private bool Consume(string chem, long quantity)
         {
             if (quantity <= 0)
-                throw new ArgumentOutOfRangeException();
+                throw new ArgumentOutOfRangeException(nameof(quantity));
 
             if (!available!.ContainsKey(chem))
                 available[chem] = 0;
@@ -59,9 +59,16 @@ namespace aoc2019
 
         public override string Part2()
         {
-            available = new Dictionary<string, long> {{"ORE", 1000000000000}};
-            Consume("FUEL", long.MaxValue);
-            return "";
+            const long capacity = 1_000_000_000_000;
+            available = new Dictionary<string, long> {{"ORE", capacity}};
+            Consume("FUEL", 1);
+
+            var oreConsumed = capacity - available["ORE"];
+            while (Produce("FUEL", Math.Max(1, available["ORE"] / oreConsumed)))
+            {
+            }
+
+            return $"{available["FUEL"]}";
         }
 
         private struct Component