Ejemplo n.º 1
0
        static void DayOne()
        {
            var masses = File
                         .ReadLines("./Data/massesForMyModules.txt")
                         .Select(m => double.TryParse(m, out var mass) ? mass : 0)
                         .Where(m => m > 0)
                         .ToList();

            var result = FuelCounterUpper.CalculateFuelForMasses(masses);
            var resultIncludingGasMass = FuelCounterUpper.CalculateFuelForMasses(masses, true);

            Console.WriteLine(
                $"The total fuel required for all the modules for my ship is {result}"
                );
            Console.WriteLine(
                $"The total fuel required for all the modules (including gas mass) for my ship is {resultIncludingGasMass}"
                );
        }
Ejemplo n.º 2
0
 public void Calculates_Correct_Fuel_Including_Gas_Mass(double[] masses, int expectedFuel)
 {
     Assert.Equal(expectedFuel, FuelCounterUpper.CalculateFuelForMasses(masses, true));
 }
Ejemplo n.º 3
0
 public void Calculates_Correct_Fuel_For_Many_Masses(double[] masses, int expectedFuel)
 {
     Assert.Equal(expectedFuel, FuelCounterUpper.CalculateFuelForMasses(masses));
 }