Advertisement
Tsvetelina_Georgieva

Chore Wars

Dec 14th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.09 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace ChoreWars
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string input = Console.ReadLine();
  11.            
  12.             int sumDIshes = 0;
  13.             int sumCleaning = 0;
  14.             int sumLaundry = 0;
  15.             int sumAll = 0;
  16.          
  17.             while (input != "wife is happy")
  18.             {
  19.                 if (input.Contains("<") && input.Contains(">"))
  20.                 {
  21.                     int indexStart = input.LastIndexOf("<");
  22.                     int indexEnd = input.IndexOf(">");
  23.                     bool isValid = false;
  24.                     for (int i = indexStart+1; i < indexEnd; i++)
  25.                     {
  26.                         if (char.IsLower(input[i]) || char.IsDigit(input[i]))
  27.                         {
  28.                             isValid = true;
  29.                         }
  30.                         else
  31.                         {
  32.                             isValid = false;
  33.                             i = indexEnd;
  34.                         }
  35.                     }
  36.  
  37.                     if (indexStart > indexEnd)
  38.                     {
  39.                         for (int i = 0; i < indexEnd; i++)
  40.                         {
  41.                             if (input[i] == '<')
  42.                             {
  43.                                 indexStart = i;
  44.                             }
  45.                         }
  46.                     }
  47.  
  48.                     if (isValid)
  49.                     {
  50.                         for (int i = indexStart + 1; i < indexEnd; i++)
  51.                         {
  52.                             char symbol = input[i];
  53.                             if (char.IsDigit(symbol) )
  54.                             {
  55.                                 int digit = int.Parse(symbol.ToString());
  56.                                 sumDIshes += digit;
  57.                             }
  58.                         }
  59.                     }
  60.  
  61.                 }
  62.                 else if (input.Contains("[") && input.Contains("]"))
  63.                 {
  64.                     int indexStart = input.LastIndexOf("[");
  65.                     int indexEnd = input.IndexOf("]");
  66.                     bool isValid = false;
  67.  
  68.                     for (int i = indexStart + 1; i < indexEnd; i++)
  69.                     {
  70.                         if (char.IsUpper(input[i]) || char.IsDigit(input[i]))
  71.                         {
  72.                             isValid = true;
  73.                         }
  74.                         else if (input[i] == '[')
  75.                         {
  76.                             indexStart = i;
  77.                         }
  78.                         else
  79.                         {
  80.                             isValid = false;
  81.                             i = indexEnd;
  82.                         }
  83.                     }
  84.  
  85.                     if (indexStart > indexEnd)
  86.                     {
  87.                         for (int i = 0; i < indexEnd; i++)
  88.                         {
  89.                             if (input[i] == '[')
  90.                             {
  91.                                 indexStart = i;
  92.                             }
  93.                         }
  94.                     }
  95.  
  96.                     if (isValid)
  97.                     {
  98.                         for (int i = indexStart + 1; i < indexEnd; i++)
  99.                         {
  100.                             char symbol = input[i];
  101.                             if (char.IsDigit(symbol))
  102.                             {
  103.                                 int digit = int.Parse(symbol.ToString());
  104.                                 sumCleaning += digit;
  105.                             }
  106.                         }
  107.                     }
  108.  
  109.                 }
  110.                 else if (input.Contains("{") && input.Contains("}"))
  111.                 {
  112.                     int indexStart = input.LastIndexOf("{");
  113.                     int indexEnd = input.IndexOf("}");
  114.  
  115.                     if (indexStart > indexEnd)
  116.                     {
  117.                         for (int i = 0; i < indexEnd; i++)
  118.                         {
  119.                             if (input[i] == '{')
  120.                             {
  121.                                 indexStart = i;
  122.                             }
  123.                         }
  124.                     }
  125.  
  126.                     for (int i = indexStart + 1; i < indexEnd; i++)
  127.                     {
  128.                         char symbol = input[i];
  129.                         if (char.IsDigit(symbol))
  130.                         {
  131.                             int digit = int.Parse(symbol.ToString());
  132.                             sumLaundry += digit;
  133.                         }
  134.                     }
  135.                 }
  136.  
  137.                 input = Console.ReadLine();
  138.  
  139.             }
  140.  
  141.             sumAll = sumDIshes + sumCleaning + sumLaundry;
  142.  
  143.             Console.WriteLine($"Doing the dishes - {sumDIshes} min.");
  144.             Console.WriteLine($"Cleaning the house - {sumCleaning} min.");
  145.             Console.WriteLine($"Doing the laundry - {sumLaundry} min.");
  146.             Console.WriteLine($"Total - {sumAll} min.");
  147.         }
  148.     }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement