stefan1919

Lego Blocks

Sep 12th, 2015
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication6
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             bool theArrayIsPossible = true;
  15.             List<List<int>> room = new List<List<int>>();
  16.             int checker = 1;
  17.             do
  18.             {
  19.                 List<int> arrayList = new List<int>();
  20.                 string[] arrayOfStrings = Console.ReadLine().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
  21.                 for (int i = 0; i < arrayOfStrings.Length; i++)
  22.                 {
  23.                     arrayList.Add(int.Parse(arrayOfStrings[i]));
  24.                 }
  25.                 room.Add(arrayList);
  26.                 checker++;
  27.             } while (checker <= 2 * n);
  28.             for (int i = n; i < 2 * n; i++)
  29.             {
  30.                 List<int> helper = new List<int>();
  31.                 helper = room[i];
  32.                 room[i].Reverse();
  33.                
  34.             }
  35.             //foreach (var item in room)
  36.             //{
  37.             //    Console.Write(string.Join(" ", item));
  38.             //    Console.WriteLine();
  39.             //}
  40.             int sum = 0;
  41.             int previousSum = room[0].Count + room[n].Count;
  42.             for (int i = 0; i < room.Count / 2; i++)
  43.             {
  44.                 sum = room[i].Count + room[n + i].Count;
  45.                 if (sum != previousSum)
  46.                 {
  47.                     theArrayIsPossible = false;
  48.                 }
  49.  
  50.             }
  51.             if (!theArrayIsPossible)
  52.             {
  53.                 int overallSum = 0;
  54.                 room.ForEach(t => overallSum += t.Count);
  55.                 Console.WriteLine("The total number of cells is: {0}", overallSum);
  56.             }
  57.             else
  58.             {
  59.                 for (int i = 0; i < room.Count / 2; i++)
  60.                 {
  61.                     Console.WriteLine("[" + string.Join(", ",room[i]) + ", " + string.Join(", ", room[n + i]) + "]");
  62.                 }
  63.             }
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment