daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jan 29th, 2018 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace PlaygroundConsole
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] size = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
  14.                 .Select(int.Parse).ToArray();
  15.  
  16.             char[,] matrix = new char[size[0], size[1]];
  17.  
  18.             for (int i = 0; i < matrix.GetLength(0); i++)
  19.             {
  20.                 char[] tokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
  21.                 .Select(char.Parse).ToArray();
  22.  
  23.                 for (int j = 0; j < matrix.GetLength(1); j++)
  24.                 {
  25.                     matrix[i, j] = tokens[j];
  26.                 }
  27.             }
  28.  
  29.             int equalSquares = 0;
  30.  
  31.             for (int i = 0; i < matrix.GetLength(0) - 1; i++)
  32.             {
  33.                 for (int j = i; j < matrix.GetLength(1) - 1; j++)
  34.                 {
  35.                     char startChar = matrix[i, j];
  36.  
  37.                     if ((matrix[i, j + 1] == startChar)
  38.                         && (matrix[i + 1, j] == startChar)
  39.                         && (matrix[i + 1, j + 1] == startChar))
  40.                     {
  41.                         equalSquares++;
  42.                     }
  43.                 }
  44.             }
  45.  
  46.             Console.WriteLine(equalSquares);
  47.         }
  48.     }
  49. }
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top