Skip to content
Permalink
Browse files

Refacto

  • Loading branch information
Elanis committed Dec 3, 2019
1 parent ab4fffe commit d3317aca13d366a55e0002b5ccc8b3869f92a368
Showing with 1 addition and 20 deletions.
  1. +0 −12 AdventOfCode2019.Tests/Day_1_2_Tests.cs
  2. +1 −8 AdventOfCode2019/Day_1_2.cs
@@ -2,18 +2,6 @@

namespace AdventOfCode2019.Tests {
public class Day_1_2_Tests {
[Theory]
[InlineData(12, 2)]
[InlineData(14, 2)]
[InlineData(1969, 654)]
[InlineData(100756, 33583)]
public void CalcFuelFromMass_X_Should_Return_Y(int mass, int fuel) {
Assert.Equal(
Day_1_1.CalcFuelFromMass(mass),
fuel
);
}

[Theory]
[InlineData(14, 2)]
[InlineData(1969, 966)]
@@ -18,18 +18,11 @@ public class Day_1_2 {
int newMass = mass;
int fuelCost = 0;

while ((newMass = CalcFuelFromMass(newMass)) > 0) {
while ((newMass = Day_1_1.CalcFuelFromMass(newMass)) > 0) {
fuelCost += newMass;
}

return fuelCost;
}

public static int CalcFuelFromMass(int mass) {
return (int)(
Math.Floor(mass / 3.0f)
- 2.0
);
}
}
}

0 comments on commit d3317ac

Please sign in to comment.
You can’t perform that action at this time.