AdventOfCode2021/day4.cs

107 lines
2.3 KiB
C#
Raw Normal View History

2022-12-17 11:57:30 +01:00
using System.Diagnostics.Metrics;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Xml;
class day4
{
string[] input;
string[] number = "7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1".Split(',');
public day4(string day)
{
input = getInput(day);
part1();
part2();
}
public string[] getInput(string day)
{
string filepath = $"../../../inputs/{day}.txt";
string[] file = File.ReadAllLines(filepath);
return file;
}
public void part1()
{
List<Field> fields = new List<Field>();
int index = 0 ;
while (index <= input.Length)
{
int rowIndex = 0;
var bingoField = new string[5, 5];
while (rowIndex < 5) {
for(int i = 0; i < 5; i++)
{
bingoField[rowIndex,i] = $"[{input[index + rowIndex].Split(' ',StringSplitOptions.RemoveEmptyEntries)[i]}]";
}
rowIndex++;
}
fields.Add(new Field(bingoField));
index += 6;
}
foreach(Field field in fields)
{
field.markNumber("13");
field.printField();
}
}
public void part2()
{
}
}
2022-12-17 09:22:51 +01:00
class Field{
string[,] bingoField = new string[5,5];
public Field(string[,] bingoField){
this.bingoField = bingoField;
}
public void markNumber(string markNumber){
2022-12-17 11:57:30 +01:00
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
if (bingoField[i, j].Contains(markNumber))
{
bingoField[i, j] = $"[-{markNumber}-]";
}
}
}
}
public void checkBingo()
{
bool bingo = false;
int checkCounter = 0;
for(int i = 0; i < 5; i++)
{
}
}
public void printField()
{
for (int i = 0; i < 5; i++)
{
for(int j = 0; j < 5; j++) {
Console.Write(bingoField[i,j]);
}
Console.WriteLine(" ");
}
Console.WriteLine("\n");
2022-12-17 09:22:51 +01:00
}
}