Advertisement
MartinZarev

Untitled

Feb 26th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Gift_Box_Coverage
  6. {
  7.     class Program
  8.     {
  9.         static void Main()
  10.         {
  11.             List<int> tasks = Console.ReadLine()
  12.                 .Split()
  13.                 .Select(int.Parse)
  14.                 .ToList();
  15.  
  16.            
  17.  
  18.             while (true)
  19.             {
  20.                 string input = Console.ReadLine();
  21.                 string[] cmdArgs = input.Split();
  22.                 string command = cmdArgs[0];
  23.  
  24.                
  25.  
  26.                 if (command== "Complete")
  27.                 {
  28.                     int index = int.Parse(cmdArgs[1]);
  29.                     int indexCheck = tasks.Count();
  30.                     if (indexCheck>=0 && index < tasks.Count())
  31.                     {
  32.                         tasks.RemoveAt(index);
  33.                         tasks.Insert(index, 0);
  34.                     }
  35.                    
  36.                    
  37.                 }
  38.                 else if (command=="Change")
  39.                 {
  40.                     int indexCheck = tasks.Count();
  41.                     int index = int.Parse(cmdArgs[1]);
  42.                     int time = int.Parse(cmdArgs[2]);
  43.                     if (indexCheck >= 0 && index < tasks.Count)
  44.                     {
  45.                         tasks.RemoveAt(index);
  46.                         tasks.Insert(index, time);
  47.                     }
  48.                    
  49.                    
  50.  
  51.                 }
  52.                 else if (command=="Drop")
  53.                 {
  54.                     int indexCheck = tasks.Count();
  55.                     int index = int.Parse(cmdArgs[1]);
  56.                     if (indexCheck >= 0 && index < tasks.Count)
  57.                     {
  58.                         tasks.RemoveAt(index);
  59.                         tasks.Insert(index, -1);
  60.                     }
  61.                    
  62.                    
  63.                 }
  64.                 else if (command=="Count")
  65.                 {
  66.                     string secondCommand = cmdArgs[1];
  67.                     if (secondCommand=="Complete")
  68.                     {
  69.                         var listB = tasks.FindAll(x => x == 0);
  70.                         int countOfCompleted = listB.Count();
  71.                         Console.WriteLine(string.Join("", countOfCompleted));
  72.                     }
  73.                     else if (secondCommand== "Incomplete")
  74.                     {
  75.                         var listC = tasks.FindAll(x => x > 0);
  76.                         int countOfIncomplete = listC.Count();
  77.                         Console.WriteLine(string.Join("", countOfIncomplete));
  78.                     }
  79.                     else if (secondCommand== "Dropped")
  80.                     {
  81.                         var listD = tasks.FindAll(x => x == -1);
  82.                         int countOfDropped = listD.Count();
  83.                         Console.WriteLine(string.Join("", countOfDropped));
  84.                     }
  85.                    
  86.                 }
  87.                 else if (command=="End")
  88.                 {
  89.                     var Incomplete = tasks.FindAll(x => x > 0);
  90.                     Console.WriteLine(string.Join(" ", Incomplete));
  91.                     break;
  92.                 }
  93.             }
  94.  
  95.            
  96.  
  97.         }
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement