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.
57 lines
1.5 KiB
57 lines
1.5 KiB
using AdventOfCode.Contracts;
|
|
using AoC.Utils;
|
|
using System;
|
|
using System.Diagnostics;
|
|
|
|
namespace AoC.TwentyTwenty
|
|
{
|
|
class One : Day
|
|
{
|
|
public override int Year => 2020;
|
|
public override int DayNumber => 1;
|
|
|
|
public override void BigBoi(string[] input)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override void Part1(string[] input)
|
|
{
|
|
int[] nums = input.ToIntArray();
|
|
|
|
for (int i = 0; i < nums.Length; i++)
|
|
{
|
|
for (int j = 0; j < nums.Length; j++)
|
|
{
|
|
if (nums[i] + nums[j] == 2020) {
|
|
Print("1", nums[i] * nums[j]);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void Part2(string[] input)
|
|
{
|
|
Stopwatch sw = Stopwatch.StartNew();
|
|
int[] nums = input.ToIntArray();
|
|
|
|
for (int i = 0; i < nums.Length; i++)
|
|
{
|
|
for (int j = 0; j < nums.Length; j++)
|
|
{
|
|
for (int k = 0; k < nums.Length; k++)
|
|
{
|
|
if (nums[i] + nums[j] + nums[k] == 2020)
|
|
{
|
|
Print("2", nums[i] * nums[j] * nums[k]);
|
|
Console.WriteLine(sw.Elapsed);
|
|
return;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |