day 6 part 1
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
7e50cb1a54
commit
93e61904ac
|
@ -44,6 +44,7 @@ public class DayTests
|
||||||
[DataRow(typeof(Day03), "198", "230")]
|
[DataRow(typeof(Day03), "198", "230")]
|
||||||
[DataRow(typeof(Day04), "4512", "1924")]
|
[DataRow(typeof(Day04), "4512", "1924")]
|
||||||
[DataRow(typeof(Day05), "5", "12")]
|
[DataRow(typeof(Day05), "5", "12")]
|
||||||
|
[DataRow(typeof(Day06), "5934", "")]
|
||||||
public void CheckTestInputs(Type dayType, string part1, string part2)
|
public void CheckTestInputs(Type dayType, string part1, string part2)
|
||||||
{
|
{
|
||||||
Day.UseTestInput = true;
|
Day.UseTestInput = true;
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
namespace aoc2021;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Day 6: <see href="https://adventofcode.com/2021/day/6"/>
|
||||||
|
/// </summary>
|
||||||
|
public sealed class Day06 : Day
|
||||||
|
{
|
||||||
|
private readonly List<int> _fishes;
|
||||||
|
public Day06() : base(6, "Lanternfish")
|
||||||
|
{
|
||||||
|
//UseTestInput = true;
|
||||||
|
_fishes = Input.First().Split(',').Select(int.Parse).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<int> DayStep(List<int> state)
|
||||||
|
{
|
||||||
|
List<int> result = new();
|
||||||
|
|
||||||
|
foreach (var fish in state)
|
||||||
|
{
|
||||||
|
switch (fish)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
result.Add(6);
|
||||||
|
result.Add(8);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result.Add(fish - 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string Part1()
|
||||||
|
{
|
||||||
|
var fishes = Enumerable.Range(0, 80).Aggregate(_fishes, (current, _) => DayStep(current));
|
||||||
|
return $"{fishes.Count}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string Part2() => "";
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
3,3,5,1,1,3,4,2,3,4,3,1,1,3,3,1,5,4,4,1,4,1,1,1,3,3,2,3,3,4,2,5,1,4,1,2,2,4,2,5,1,2,2,1,1,1,1,4,5,4,3,1,4,4,4,5,1,1,4,3,4,2,1,1,1,1,5,2,1,4,2,4,2,5,5,5,3,3,5,4,5,1,1,5,5,5,2,1,3,1,1,2,2,2,2,1,1,2,1,5,1,2,1,2,5,5,2,1,1,4,2,1,4,2,1,1,1,4,2,5,1,5,1,1,3,1,4,3,1,3,2,1,3,1,4,1,2,1,5,1,2,1,4,4,1,3,1,1,1,1,1,5,2,1,5,5,5,3,3,1,2,4,3,2,2,2,2,2,4,3,4,4,4,1,2,2,3,1,1,4,1,1,1,2,1,4,2,1,2,1,1,2,1,5,1,1,3,1,4,3,2,1,1,1,5,4,1,2,5,2,2,1,1,1,1,2,3,3,2,5,1,2,1,2,3,4,3,2,1,1,2,4,3,3,1,1,2,5,1,3,3,4,2,3,1,2,1,4,3,2,2,1,1,2,1,4,2,4,1,4,1,4,4,1,4,4,5,4,1,1,1,3,1,1,1,4,3,5,1,1,1,3,4,1,1,4,3,1,4,1,1,5,1,2,2,5,5,2,1,5
|
|
@ -0,0 +1 @@
|
||||||
|
3,4,3,1,2
|
Loading…
Reference in New Issue