Advertisement
Stan0033

Untitled

Aug 16th, 2022
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.50 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5. using System.Text;
  6. namespace apps
  7. {
  8.     class Program
  9.     {
  10.         static void Main()
  11.         {
  12.             string[] AreasOfWhiteTiles = Console.ReadLine().Split(' ').ToArray();
  13.             string[] AreasOfGrayTiles = Console.ReadLine().Split(' ').ToArray();
  14.             //Console.WriteLine("---------------------------------------");
  15.             int loops = 0;
  16.             List<int> White_Tiles = new List<int>();
  17.             List<int> Gray_Tiles = new List<int>();
  18.             Dictionary<string, int> Tile_Categories = new Dictionary<string, int>();
  19.  
  20.             Tile_Categories.Add("Floor", 0);
  21.             Tile_Categories.Add("Countertop", 0);
  22.             Tile_Categories.Add("Oven", 0);
  23.             Tile_Categories.Add("Sink", 0);
  24.  
  25.  
  26.             Tile_Categories.Add("Wall", 0);
  27.  
  28.             foreach (string AreaOfWhiteTile in AreasOfWhiteTiles) { White_Tiles.Add(int.Parse(AreaOfWhiteTile)); }
  29.  
  30.             foreach (string AreaOfGrayTile in AreasOfGrayTiles) { Gray_Tiles.Add(int.Parse(AreaOfGrayTile)); }
  31.            
  32.             List<int> FormedTiles = new List<int>();
  33.  
  34.  
  35.             //=================================================================================================
  36.             //=================================================================================================
  37.             while (true)
  38.             {
  39.  
  40.             //Console.WriteLine(String.Join(", ", White_Tiles));
  41.            //  Console.WriteLine(String.Join(", ", Gray_Tiles));
  42.                
  43.  
  44.                 int LastElementOfWhites = White_Tiles[White_Tiles.Count-1];
  45.                 int FirstElementOfGrays = Gray_Tiles[0];
  46.                 int FirstIndexOfWhite = White_Tiles.Count-1;
  47.                 int LastIndexOfGray = 0;
  48.                 White_Tiles.RemoveAt(FirstIndexOfWhite); Gray_Tiles.RemoveAt(LastIndexOfGray);
  49.                
  50.                 int WhitePlusGrayTiles = LastElementOfWhites + FirstElementOfGrays;
  51.              // Console.WriteLine($"{LastElementOfWhites} + {FirstElementOfGrays} = {WhitePlusGrayTiles}");
  52.  
  53.                 switch (WhitePlusGrayTiles)
  54.                 {
  55.                     case 40: Tile_Categories["Sink"]++;  FormedTiles.Add(WhitePlusGrayTiles); break;
  56.                     case 50: Tile_Categories["Oven"]++;  ; FormedTiles.Add(WhitePlusGrayTiles); break;
  57.                     case 60: Tile_Categories["Countertop"]++;   FormedTiles.Add(WhitePlusGrayTiles); break;
  58.                     case 70: Tile_Categories["Wall"]++;   FormedTiles.Add(WhitePlusGrayTiles); break;
  59.                     default:
  60.                         if (LastElementOfWhites == FirstElementOfGrays)
  61.                         {
  62.                             Tile_Categories["Floor"]++;  FormedTiles.Add(WhitePlusGrayTiles);  
  63.                         }
  64.                         else
  65.                         {
  66.                            
  67.                             Gray_Tiles.Add(FirstElementOfGrays);
  68.  
  69.                             int halfOfWhite = LastElementOfWhites /2;
  70.                             White_Tiles.Add(halfOfWhite);
  71.                            
  72.  
  73.  
  74.                         }
  75.                         break;
  76.  
  77.  
  78.                 }
  79.                 if (White_Tiles.Count == 0 || Gray_Tiles.Count == 0) { break; }
  80.              //  loops++;
  81.               //  if (loops > 10) { break; }
  82.  
  83.  
  84.             }
  85.                 string whiteLeft = string.Empty;
  86.                 string grayLeft = string.Empty;
  87.                 if (White_Tiles.Count > 0)
  88.                 {
  89.                     whiteLeft = string.Join(", ", White_Tiles);
  90.                 }
  91.                 else
  92.                 {
  93.                     whiteLeft = "none";
  94.                 }
  95.                 if (Gray_Tiles.Count > 0)
  96.                 {
  97.                     grayLeft = string.Join(", ", Gray_Tiles);
  98.                 }
  99.                 else
  100.                 {
  101.                     grayLeft = "none";
  102.                 }
  103.                 Console.WriteLine($"White tiles left: {whiteLeft}");
  104.                 Console.WriteLine($"Grey tiles left: {grayLeft}");
  105.                 foreach (var v in Tile_Categories)
  106.                 {
  107.                     if (v.Value > 0)
  108.                     {
  109.                         Console.WriteLine($"{v.Key}: {v.Value}");
  110.                     }
  111.                 }
  112.  
  113.                 //Console.WriteLine($"Formed tiles: {string.Join(" ",FormedTiles )}");
  114.             }
  115.         }
  116.     }
  117.  
  118.  
  119.  
  120.  
  121.        
  122.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement