Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace darkest
- {
- class Program
- {
- static int[,] pixels = new int[,] {
- { 1,2,3,4 },
- { 2,3,5,7 },
- { 4,7,9,9 },
- { 9,5,3,2 }
- };
- static void Main(string[] args)
- {
- process(pixels);
- }
- private static void process(int[,] pixels)
- {
- int w = pixels.GetLength(0);
- int h = pixels.GetLength(1);
- int[,] darkestNearby = new int[w, h];
- char[,] result = new char[w, h];
- for (int y = 0; y < h; y++)
- {
- int a = pixels[y, 0];
- for (int x = 0; x < w - 1; x++)
- {
- int b = pixels[y, x + 1];
- if (a < b)
- {
- darkestNearby[y, x] = b;
- result[y, x] = '>';
- }
- else if (a > b)
- {
- darkestNearby[y, x + 1] = a;
- result[y, x + 1] = '<';
- }
- a = b;
- }
- }
- for (int x = 0; x < w; x++)
- {
- int a = pixels[0, x];
- for (int y = 0; y < h - 1; y++)
- {
- int b = pixels[y + 1, x];
- if (a < b)
- {
- if (darkestNearby[y, x] < b)
- {
- result[y, x] = 'v';
- }
- }
- else if (a > b)
- {
- if (darkestNearby[y + 1, x] < a)
- {
- result[y + 1, x] = '^';
- }
- }
- a = b;
- }
- }
- for (int x = 0; x < w; x++)
- {
- for (int y = 0; y < h; y++)
- {
- char c = result[x, y];
- Console.Write(c == '\0' ? 'o' : c);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement