public FullImage combineTiles(Tile[][] image) { string[,] fullImage = new string[LINE_WIDTH, LINE_WIDTH]; string[] combinedTiles = new string[LINE_WIDTH]; string line = ""; int lc = 0; for (int i = 0; i < TILES_HORIZONTAL; i++) { for (int k = 1; k < 9; k++) { for (int j = 0; j < TILES_VERTICAL; j++) { line += image[i][j].getLine(k); } combinedTiles[lc] = line; line = ""; lc++; } } for (int i = 0; i < combinedTiles.Length; i++) { for (int j = 0; j < combinedTiles[0].Length; j++) { fullImage[i,j] = combinedTiles[i][j].ToString(); } } FullImage fullImageInstance = new FullImage(fullImage); return fullImageInstance; }
static void Main(string[] args) { JurassicJigsaw self = new JurassicJigsaw(); self.readFile("./day20/day20.txt"); self.parseFileContents(); Tile[][] image = self.buildImage(); FullImage fullImage = self.combineTiles(image); for (int i = 0; i < 10; i++) { fullImage.setTileState(i); int numberOfMonsters = fullImage.findMonsters(); Console.WriteLine("{0} monsters found at state {1}", numberOfMonsters, i); if (numberOfMonsters > 0) { int waterRoughness = fullImage.countWaterRoughness(numberOfMonsters); } } }