TheBulgarianWolf

Hourglass Hackerrank

May 9th, 2021
632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System.CodeDom.Compiler;
  2. using System.Collections.Generic;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Diagnostics.CodeAnalysis;
  6. using System.Globalization;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Reflection;
  10. using System.Runtime.Serialization;
  11. using System.Text.RegularExpressions;
  12. using System.Text;
  13. using System;
  14.  
  15.  
  16.  
  17. class Solution
  18. {
  19.     public static void Main(string[] args)
  20.     {
  21.  
  22.         List<List<int>> arr = new List<List<int>>();
  23.  
  24.         for (int i = 0; i < 6; i++)
  25.         {
  26.             arr.Add(Console.ReadLine().TrimEnd().Split(' ').ToList().Select(arrTemp => Convert.ToInt32(arrTemp)).ToList());
  27.         }
  28.        
  29.         int bestSum = int.MinValue;
  30.             int currentSum = 0;
  31.             for(int row = 0; row < 4; row++)
  32.             {
  33.                 for(int col = 0; col < 4; col++)
  34.                 {
  35.                     currentSum = arr[row][col] + arr[row][col+1] + arr[row][col+2] + arr[row+1][col+1]+ arr[row+2][col] + arr[row+2][col+1] + arr[row+2][col+2];
  36.                     if(currentSum > bestSum)
  37.                     {
  38.                         bestSum = currentSum;
  39.                     }
  40.                     currentSum = 0;
  41.                 }
  42.             }
  43.             Console.WriteLine(bestSum);
  44.     }
  45. }
Add Comment
Please, Sign In to add comment