Tidy Day baseclass and add empty day4
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
b78203fb09
commit
8bf051f52c
|
@ -26,4 +26,4 @@ namespace aoc.tests
|
||||||
Assert.AreEqual("1718180100", _day3.Part2());
|
Assert.AreEqual("1718180100", _day3.Part2());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
using aoc2020;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
namespace aoc.tests
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class Day4Test
|
||||||
|
{
|
||||||
|
private Day4 _day4;
|
||||||
|
|
||||||
|
[TestInitialize]
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
_day4 = new Day4();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestPart1()
|
||||||
|
{
|
||||||
|
Assert.AreEqual("", _day4.Part1());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestPart2()
|
||||||
|
{
|
||||||
|
Assert.AreEqual("", _day4.Part2());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,8 +9,8 @@ namespace aoc2020
|
||||||
{
|
{
|
||||||
public abstract int DayNumber { get; }
|
public abstract int DayNumber { get; }
|
||||||
|
|
||||||
public virtual IEnumerable<string> Input =>
|
protected virtual IEnumerable<string> Input =>
|
||||||
File.ReadLines($"input/day{DayNumber}.in");
|
File.ReadLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"input/day{DayNumber}.in"));
|
||||||
|
|
||||||
public abstract string Part1();
|
public abstract string Part1();
|
||||||
public abstract string Part2();
|
public abstract string Part2();
|
||||||
|
@ -20,33 +20,24 @@ namespace aoc2020
|
||||||
Console.WriteLine($"Day {DayNumber}:");
|
Console.WriteLine($"Day {DayNumber}:");
|
||||||
var s = new Stopwatch();
|
var s = new Stopwatch();
|
||||||
|
|
||||||
if (verbose) s.Start();
|
s.Start();
|
||||||
|
|
||||||
var part1 = Part1();
|
var part1 = Part1();
|
||||||
|
s.Stop();
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
s.Stop();
|
|
||||||
Console.WriteLine($"Part 1 elapsed: {s.ElapsedMilliseconds}ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine(part1);
|
Console.WriteLine(part1);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
Console.WriteLine($"{s.ElapsedMilliseconds}ms elapsed");
|
||||||
s.Reset();
|
|
||||||
s.Start();
|
s.Reset();
|
||||||
}
|
|
||||||
|
s.Start();
|
||||||
var part2 = Part2();
|
var part2 = Part2();
|
||||||
|
s.Stop();
|
||||||
|
Console.WriteLine(part2);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
Console.WriteLine($"{s.ElapsedMilliseconds}ms elapsed");
|
||||||
s.Stop();
|
|
||||||
Console.WriteLine($"Part 2 elapsed: {s.ElapsedMilliseconds}ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine(part2);
|
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,19 +32,13 @@ namespace aoc2020
|
||||||
|
|
||||||
public override string Part2()
|
public override string Part2()
|
||||||
{
|
{
|
||||||
var slopes = new[]
|
var xSlopes = new[] {1, 3, 5, 7, 1};
|
||||||
{
|
var ySlopes = new[] {1, 1, 1, 1, 2};
|
||||||
(1, 1),
|
|
||||||
(3, 1),
|
|
||||||
(5, 1),
|
|
||||||
(7, 1),
|
|
||||||
(1, 2)
|
|
||||||
};
|
|
||||||
|
|
||||||
return slopes
|
return xSlopes.Zip(ySlopes)
|
||||||
.Select(s => CountSlope(s.Item1, s.Item2))
|
.Select(s => CountSlope(s.Item1, s.Item2))
|
||||||
.Aggregate((acc, i) => acc * i)
|
.Aggregate((acc, i) => acc * i)
|
||||||
.ToString();
|
.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
namespace aoc2020
|
||||||
|
{
|
||||||
|
public sealed class Day4 : Day
|
||||||
|
{
|
||||||
|
public override int DayNumber => 4;
|
||||||
|
|
||||||
|
public override string Part1()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string Part2()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue