Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- public class Program
- {
- public static void Main()
- {
- int dishesTime =0;
- int cleaningTime =0;
- int laundryTime =0;
- string dishesPattern = @"<(?<dishes>[a-z0-9]+)>";
- string cleaningPattern = @"\[(?<cleaning>[A-Z0-9]+)\]";
- string laundryPattern = @"{(?<laundry>.+)}";
- while (true)
- {
- string command = Console.ReadLine();
- if (command == "wife is happy")
- {
- break;
- }
- if (Regex.IsMatch(command,dishesPattern))
- {
- Match matchedDishes = Regex.Match(command,dishesPattern);
- string dishes = matchedDishes.Groups["dishes"].Value;
- for (int i=0; i<dishes.Length; i++)
- {
- char curr = dishes[i];
- if (char.IsDigit(curr))
- {
- int time = int.Parse(curr.ToString());
- dishesTime+=time;
- }
- }
- }
- else if (Regex.IsMatch(command,cleaningPattern))
- {
- Match matchedCleaning = Regex.Match(command,cleaningPattern);
- string cleaning = matchedCleaning.Groups["cleaning"].Value;
- for (int i=0; i<cleaning.Length; i++)
- {
- char curr = cleaning[i];
- if (char.IsDigit(curr))
- {
- int time = int.Parse(curr.ToString());
- cleaningTime += time;
- }
- }
- }
- else if (Regex.IsMatch(command,laundryPattern))
- {
- Match matchedLaundry = Regex.Match(command,laundryPattern);
- string laundry = matchedLaundry.Groups["laundry"].Value;
- for (int i=0; i<laundry.Length; i++)
- {
- char curr = laundry[i];
- if (char.IsDigit(curr))
- {
- int time = int.Parse(curr.ToString());
- laundryTime+=time;
- }
- }
- }
- }
- Console.WriteLine("Doing the dishes - {0} min.",dishesTime);
- Console.WriteLine("Cleaning the house - {0} min.",cleaningTime);
- Console.WriteLine("Doing the laundry - {0} min.",laundryTime);
- Console.WriteLine("Total - {0} min.",dishesTime+cleaningTime+laundryTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement