fix day 11 part 1
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
405339031e
commit
beb9fbba0b
|
@ -18,7 +18,7 @@ namespace aoc2020.test
|
||||||
[DataRow(typeof(Day08), "1654", "833")]
|
[DataRow(typeof(Day08), "1654", "833")]
|
||||||
[DataRow(typeof(Day09), "138879426", "23761694")]
|
[DataRow(typeof(Day09), "138879426", "23761694")]
|
||||||
[DataRow(typeof(Day10), "1980", "4628074479616")]
|
[DataRow(typeof(Day10), "1980", "4628074479616")]
|
||||||
[DataRow(typeof(Day11), "", "")]
|
[DataRow(typeof(Day11), "2303", "")]
|
||||||
public void CheckAllDays(Type dayType, string part1, string part2)
|
public void CheckAllDays(Type dayType, string part1, string part2)
|
||||||
{
|
{
|
||||||
// create day instance
|
// create day instance
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
@ -22,7 +23,15 @@ namespace aoc2020
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var next = prev.StepPart1();
|
var next = prev.StepPart1();
|
||||||
if (next.Grid == prev.Grid) break;
|
var same = true;
|
||||||
|
for (var i = 0; i < next.Grid.Length; i++)
|
||||||
|
if (!next.Grid[i].SequenceEqual(prev.Grid[i]))
|
||||||
|
{
|
||||||
|
same = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (same) break;
|
||||||
prev = next;
|
prev = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +44,15 @@ namespace aoc2020
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var next = prev.StepPart2();
|
var next = prev.StepPart2();
|
||||||
if (next.Grid == prev.Grid) break;
|
var same = true;
|
||||||
|
for (var i = 0; i < next.Grid.Length; i++)
|
||||||
|
if (!next.Grid[i].SequenceEqual(prev.Grid[i]))
|
||||||
|
{
|
||||||
|
same = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (same) break;
|
||||||
prev = next;
|
prev = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,12 +75,19 @@ namespace aoc2020
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void PrintBoard()
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
|
foreach (var line in Grid)
|
||||||
|
Console.WriteLine(line);
|
||||||
|
}
|
||||||
|
|
||||||
public int TotalSeated =>
|
public int TotalSeated =>
|
||||||
Grid.Sum(l => l.Count(c => c == '#'));
|
Grid.Sum(l => l.Count(c => c == '#'));
|
||||||
|
|
||||||
public LifeGame StepPart1()
|
public LifeGame StepPart1()
|
||||||
{
|
{
|
||||||
var next = new LifeGame {_h = _h, _w = _w, Grid = Grid};
|
var next = new LifeGame {_h = _h, _w = _w, Grid = Grid.Select(s => s.ToArray()).ToArray()};
|
||||||
for (var y = 0; y < _h; y++)
|
for (var y = 0; y < _h; y++)
|
||||||
for (var x = 0; x < _w; x++)
|
for (var x = 0; x < _w; x++)
|
||||||
next.Grid[y][x] = Grid[y][x] switch
|
next.Grid[y][x] = Grid[y][x] switch
|
||||||
|
@ -73,6 +97,7 @@ namespace aoc2020
|
||||||
_ => Grid[y][x]
|
_ => Grid[y][x]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// next.PrintBoard();
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue