Created
September 12, 2017 18:50
-
-
Save Svetomech/cd8d3f8365fbc40b39f8af4fa66e07e7 to your computer and use it in GitHub Desktop.
"There is no Spoon - Episode 1" CodinGame solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Player | |
{ | |
static void Main(string[] args) | |
{ | |
int width = int.Parse(Console.ReadLine()); | |
int height = int.Parse(Console.ReadLine()); | |
var grid = new char[width, height]; | |
for (int i = 0; i < height; i++) | |
{ | |
string line = Console.ReadLine(); | |
for (int j = 0; j < width; j++) | |
{ | |
grid[j, i] = line[j]; | |
} | |
} | |
for (int i = 0; i < height; i++) | |
{ | |
for (int j = 0; j < width; j++) | |
{ | |
if (grid[j, i] == '.') continue; | |
int right = j; | |
while (++right < width && grid[right, i] == '.'); | |
string rightNeighbour = right < width && (grid[right, i] != '.') ? $"{right} {i}" : "-1 -1"; | |
int down = i; | |
while (++down < height && grid[j, down] == '.'); | |
string downNeighbour = down < height && (grid[j, down] != '.') ? $"{j} {down}" : "-1 -1"; | |
Console.WriteLine($"{j} {i} {rightNeighbour} {downNeighbour}"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment