Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
Refacto
Browse files Browse the repository at this point in the history
  • Loading branch information
Elanis committed Dec 3, 2019
1 parent ab4fffe commit d3317ac
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
12 changes: 0 additions & 12 deletions AdventOfCode2019.Tests/Day_1_2_Tests.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@


namespace AdventOfCode2019.Tests { namespace AdventOfCode2019.Tests {
public class Day_1_2_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] [Theory]
[InlineData(14, 2)] [InlineData(14, 2)]
[InlineData(1969, 966)] [InlineData(1969, 966)]
Expand Down
9 changes: 1 addition & 8 deletions AdventOfCode2019/Day_1_2.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,18 +18,11 @@ public static int CalcFinalFuelFromMass(int mass) {
int newMass = mass; int newMass = mass;
int fuelCost = 0; int fuelCost = 0;


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


return fuelCost; 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.