diff --git a/Program.cs b/Program.cs index f1d42df..e0d7881 100644 --- a/Program.cs +++ b/Program.cs @@ -1,4 +1,4 @@  using AdventOfCode2021; -var day = new day3("day3"); \ No newline at end of file +var day = new day4("day4"); \ No newline at end of file diff --git a/day4.cs b/day4.cs index 61947f8..9367ed2 100644 --- a/day4.cs +++ b/day4.cs @@ -1,3 +1,67 @@ +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 fields = new List(); + 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() + { + + } +} + class Field{ string[,] bingoField = new string[5,5]; @@ -6,9 +70,38 @@ class Field{ this.bingoField = bingoField; } public void markNumber(string markNumber){ - int row = 5; - int columnn = 5; + 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"); + + - } } \ No newline at end of file diff --git a/inputs/day4.txt b/inputs/day4.txt new file mode 100644 index 0000000..fb89fd6 --- /dev/null +++ b/inputs/day4.txt @@ -0,0 +1,17 @@ +22 13 17 11 0 + 8 2 23 4 24 +21 9 14 16 7 + 6 10 3 18 5 + 1 12 20 15 19 + + 3 15 0 2 22 + 9 18 13 17 5 +19 8 7 25 23 +20 11 10 24 4 +14 21 16 12 6 + +14 21 17 24 4 +10 16 15 9 19 +18 8 23 26 20 +22 11 13 6 5 + 2 0 12 3 7 \ No newline at end of file