work on day 14
This commit is contained in:
parent
36bb28af87
commit
1bde67a32c
|
@ -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
|
||||
|
||||
|
|
3
Day12.cs
3
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()
|
||||
|
|
15
Day14.cs
15
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
|
||||
|
|
Loading…
Reference in New Issue