You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.4 KiB
54 lines
1.4 KiB
using AdventOfCode.Contracts;
|
|
using System;
|
|
|
|
namespace AoC.TwentyTwenty
|
|
{
|
|
namespace AoC.TwentyTwenty
|
|
{
|
|
class Three : Day
|
|
{
|
|
public override int Year => 2020;
|
|
public override int DayNumber => 3;
|
|
|
|
public override void BigBoi(string[] input)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override void Part1(string[] input)
|
|
{
|
|
Print("1", Numbers(input, 1, 3));
|
|
}
|
|
|
|
public override void Part2(string[] input)
|
|
{
|
|
var thing =
|
|
Numbers(input, 1, 1) *
|
|
Numbers(input, 1, 3) *
|
|
Numbers(input, 1, 5) *
|
|
Numbers(input, 1, 7) *
|
|
Numbers(input, 2, 1);
|
|
|
|
Print("2", thing);
|
|
}
|
|
|
|
public static long Numbers(string[] input, int rows, int columns)
|
|
{
|
|
int cursor = 0;
|
|
long trees = 0;
|
|
|
|
for (int i = 0; i < input.Length; i += rows)
|
|
{
|
|
if (input[i][cursor % input[i].Length] == '#')
|
|
{
|
|
trees += 1;
|
|
}
|
|
|
|
cursor += columns;
|
|
}
|
|
|
|
return trees;
|
|
}
|
|
}
|
|
}
|
|
} |