26 lines
507 B
C#
26 lines
507 B
C#
|
string input;
|
||
|
using (var sr = new System.IO.StreamReader("../inputs/day6.txt"))
|
||
|
input = sr.ReadToEnd();
|
||
|
|
||
|
var startPop = input.Split(",").Select(int.Parse).ToList();
|
||
|
var pop = new long[9];
|
||
|
|
||
|
foreach (var fish in startPop)
|
||
|
pop[fish] += 1;
|
||
|
|
||
|
for (int i = 0; i < 256; i++)
|
||
|
{
|
||
|
long newFishes = pop[0];
|
||
|
|
||
|
for (int j = 0; j < 8; j++)
|
||
|
pop[j] = pop[j + 1];
|
||
|
|
||
|
pop[8] = newFishes;
|
||
|
pop[6] += newFishes;
|
||
|
|
||
|
if (i == 79)
|
||
|
Console.WriteLine(pop.Sum());
|
||
|
}
|
||
|
|
||
|
Console.WriteLine(pop.Sum());
|