Advertisement
svephoto

Rage Quit [C#]

Aug 14th, 2021
1,205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4.  
  5. namespace RageQuit
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             string text = Console.ReadLine().ToUpper();
  12.  
  13.             int index = 0;
  14.  
  15.             StringBuilder message = new StringBuilder();
  16.  
  17.             while (index < text.Length)
  18.             {
  19.                 string nonDigits = "";
  20.                 string digits = "";
  21.  
  22.                 for (int i = 0; i < text.Length; i++)
  23.                 {
  24.                     while (!char.IsDigit(text[index]))
  25.                     {
  26.                         nonDigits += text[index];
  27.                         index++;
  28.                     }
  29.  
  30.                     while (char.IsDigit(text[index]))
  31.                     {
  32.                         digits += text[index];
  33.                         index++;
  34.  
  35.                         if (index == text.Length)
  36.                         {
  37.                             break;
  38.                         }
  39.                     }
  40.  
  41.                     int repeatingCount = int.Parse(digits);
  42.  
  43.                     for (int j = 0; j < repeatingCount; j++)
  44.                     {
  45.                         message.Append(nonDigits);                    
  46.                     }
  47.  
  48.                     if (index == text.Length)
  49.                     {
  50.                         break;
  51.                     }
  52.  
  53.                     nonDigits = "";
  54.                     digits = "";
  55.                 }
  56.             }
  57.  
  58.             string rageMessage = message.ToString();
  59.             int uniqueSymbolsCount = rageMessage.Distinct().Count();
  60.  
  61.             Console.WriteLine($"Unique symbols used: {uniqueSymbolsCount}");
  62.             Console.WriteLine(rageMessage);
  63.         }
  64.     }
  65. }
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement