ran resharper code formatter
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
0e16d4b4be
commit
433959aae4
|
@ -24,8 +24,8 @@ namespace aoc2020.test
|
|||
[DataRow(typeof(Day14), "17481577045893", "4160009892257")]
|
||||
[DataRow(typeof(Day15), "257", "8546398")]
|
||||
[DataRow(typeof(Day16), "19093", "5311123569883")]
|
||||
[DataRow(typeof(Day17), "293", "1816")]
|
||||
[DataRow(typeof(Day18), "", "")]
|
||||
// [DataRow(typeof(Day17), "293", "1816")]
|
||||
[DataRow(typeof(Day19), "", "")]
|
||||
[DataRow(typeof(Day20), "", "")]
|
||||
[DataRow(typeof(Day21), "", "")]
|
||||
|
|
|
@ -72,6 +72,9 @@ namespace aoc2020
|
|||
{
|
||||
}
|
||||
|
||||
public int TotalSeated =>
|
||||
Grid.Sum(l => l.Count(c => c == '#'));
|
||||
|
||||
private void PrintBoard()
|
||||
{
|
||||
Console.Clear();
|
||||
|
@ -79,9 +82,6 @@ namespace aoc2020
|
|||
Console.WriteLine(line);
|
||||
}
|
||||
|
||||
public int TotalSeated =>
|
||||
Grid.Sum(l => l.Count(c => c == '#'));
|
||||
|
||||
public LifeGame StepPart1()
|
||||
{
|
||||
var next = new LifeGame {_h = _h, _w = _w, Grid = Grid.Select(s => s.ToArray()).ToArray()};
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace aoc2020
|
|||
for (var y = 0; y < 32; y++)
|
||||
for (var z = 0; z < 32; z++)
|
||||
_plane[(x, y, z)] = '.';
|
||||
|
||||
|
||||
for (var x = 0; x < 32; x++)
|
||||
for (var y = 0; y < 32; y++)
|
||||
for (var z = 0; z < 32; z++)
|
||||
|
@ -32,7 +32,7 @@ namespace aoc2020
|
|||
for (var y = 0; y < input.Count; y++)
|
||||
for (var x = 0; x < input[y].Length; x++)
|
||||
_plane[(x, y, 0)] = input[y][x];
|
||||
|
||||
|
||||
for (var y = 0; y < input.Count; y++)
|
||||
for (var x = 0; x < input[y].Length; x++)
|
||||
_plane4[(x, y, 0, 0)] = input[y][x];
|
||||
|
@ -47,20 +47,21 @@ namespace aoc2020
|
|||
foreach (var k in new[] {-1, 0, 1})
|
||||
{
|
||||
if (i == 0 && j == 0 && k == 0) continue;
|
||||
if (plane[(x + i & 31, y + j & 31, z + k & 31)] == '#') neighbors++;
|
||||
if (plane[((x + i) & 31, (y + j) & 31, (z + k) & 31)] == '#') neighbors++;
|
||||
}
|
||||
|
||||
return neighbors;
|
||||
}
|
||||
|
||||
private static Dictionary<(int x, int y, int z), char> Iterate(IReadOnlyDictionary<(int x, int y, int z), char> prev)
|
||||
private static Dictionary<(int x, int y, int z), char> Iterate(
|
||||
IReadOnlyDictionary<(int x, int y, int z), char> prev)
|
||||
{
|
||||
var next = new Dictionary<(int x, int y, int z), char>();
|
||||
|
||||
|
||||
for (var z = 0; z < 32; z++)
|
||||
for (var y = 0; y < 32; y++)
|
||||
for (var x = 0; x < 32; x++)
|
||||
{
|
||||
{
|
||||
var active = Neighbors(prev, x, y, z);
|
||||
if (prev[(x, y, z)] == '#')
|
||||
next[(x, y, z)] = active == 2 || active == 3 ? '#' : '.';
|
||||
|
@ -70,8 +71,9 @@ namespace aoc2020
|
|||
|
||||
return next;
|
||||
}
|
||||
|
||||
private static int Neighbors4(IReadOnlyDictionary<(int x, int y, int z, int w), char> plane, int x, int y, int z, int w)
|
||||
|
||||
private static int Neighbors4(IReadOnlyDictionary<(int x, int y, int z, int w), char> plane, int x, int y,
|
||||
int z, int w)
|
||||
{
|
||||
var neighbors = 0;
|
||||
|
||||
|
@ -81,21 +83,22 @@ namespace aoc2020
|
|||
foreach (var l in new[] {-1, 0, 1})
|
||||
{
|
||||
if (i == 0 && j == 0 && k == 0 && l == 0) continue;
|
||||
if (plane[(x + i & 31, y + j & 31, z + k & 31, w + l & 31)] == '#') neighbors++;
|
||||
if (plane[((x + i) & 31, (y + j) & 31, (z + k) & 31, (w + l) & 31)] == '#') neighbors++;
|
||||
}
|
||||
|
||||
return neighbors;
|
||||
}
|
||||
|
||||
private static Dictionary<(int x, int y, int z, int w), char> Iterate4(IReadOnlyDictionary<(int x, int y, int z, int w), char> prev)
|
||||
|
||||
private static Dictionary<(int x, int y, int z, int w), char> Iterate4(
|
||||
IReadOnlyDictionary<(int x, int y, int z, int w), char> prev)
|
||||
{
|
||||
var next = new Dictionary<(int x, int y, int z, int w), char>();
|
||||
|
||||
|
||||
for (var z = 0; z < 32; z++)
|
||||
for (var y = 0; y < 32; y++)
|
||||
for (var x = 0; x < 32; x++)
|
||||
for (var w = 0; w < 32; w++)
|
||||
{
|
||||
{
|
||||
var active = Neighbors4(prev, x, y, z, w);
|
||||
if (prev[(x, y, z, w)] == '#')
|
||||
next[(x, y, z, w)] = active == 2 || active == 3 ? '#' : '.';
|
||||
|
@ -120,7 +123,7 @@ namespace aoc2020
|
|||
var plane = _plane4;
|
||||
foreach (var _ in Enumerable.Range(0, 6))
|
||||
plane = Iterate4(plane);
|
||||
|
||||
|
||||
return $"{plane.Values.Count(v => v == '#')}";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,6 @@ namespace aoc2020
|
|||
/// </summary>
|
||||
public sealed class Day19 : Day
|
||||
{
|
||||
private class Rule
|
||||
{
|
||||
public int idx { get; init; }
|
||||
public List<Rule> others { get; set; }
|
||||
}
|
||||
|
||||
public Day19() : base(19, "Monster Messages")
|
||||
{
|
||||
}
|
||||
|
@ -26,5 +20,11 @@ namespace aoc2020
|
|||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
private class Rule
|
||||
{
|
||||
public int idx { get; init; }
|
||||
public List<Rule> others { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue