Some reorg so I can have the original inputs

This commit is contained in:
2019-12-02 21:06:11 -05:00
parent 127a57221a
commit 8d4155f244
7 changed files with 120 additions and 2 deletions

47
Day1/Day1.cs Normal file
View File

@@ -0,0 +1,47 @@
using System;
using System.IO;
namespace Advent
{
public static class Day1
{
public static void Execute()
{
var lines = File.ReadAllLines(@".\Day1\input.txt");
var total = 0.0;
foreach (var line in lines)
{
var mass = double.Parse(line);
var fuel = CalculateFuel(mass);
total += fuel;
}
Console.WriteLine(total);
}
private static double CalculateFuel(double mass)
{
var totalFuel = 0.0;
var fuel = Math.Floor(mass / 3) - 2;
totalFuel += fuel;
while (fuel > 2)
{
fuel = Math.Floor(fuel / 3) - 2;
if (fuel < 0)
fuel = 0;
totalFuel += fuel;
}
return totalFuel;
}
}
}