AdventOfCode2022/Kalender/day10.cs
2022-12-10 08:36:39 +01:00

59 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Kalender
{
internal class day10
{
static string file = "../../../Kalender/files/day10.txt";
static string[] lines = File.ReadAllLines(file);
static public void part1()
{
int cycle = 0;
int x = 1;
int result = 0;
foreach (string line in lines)
{
if(line != "noop")
{
x += Convert.ToInt32(line.Substring(4));
}
cycle += 2;
switch (cycle)
{
case 20:
result += (cycle * x);
break;
case 60:
result += (cycle * x);
break;
case 100:
result += (cycle * x);
break;
case 140:
result += (cycle * x);
break;
case 180:
result += (cycle * x);
break;
case 220:
result += (cycle * x);
break;
}
}
Console.WriteLine($"Part 1: {result}");
}
}
}