emilia98

Rage Quit [Hristo]

Aug 19th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Text.RegularExpressions;
  7.  
  8. namespace Task_3
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             var input = Console.ReadLine();
  15.             //string letterCounter = "";
  16.             //Dictionary<string, int> dictLetterDigit = new Dictionary<string, int>();
  17.            
  18.             string pattern = "([^0-9]+[0-9]+)";
  19.             Regex regex = new Regex(pattern);
  20.             MatchCollection m = regex.Matches(input);
  21.             StringBuilder result = new StringBuilder();
  22.             var uniqueSymbols = new HashSet<char>();
  23.             //int digit = 0;
  24.  
  25.             foreach (var word in m)
  26.             {
  27.                 //letters = string.Empty;
  28.                 string wordToString = word.ToString();
  29.  
  30.  
  31.                 int index = 0;
  32.                 string number = String.Empty;
  33.                 string symbols = String.Empty;
  34.  
  35.                 while(index < wordToString.Length)
  36.                 {
  37.                     if (wordToString[index] >= '0' && wordToString[index] <= '9')
  38.                     {
  39.                         number += wordToString[index];
  40.                     }
  41.                     else
  42.                     {
  43.                         symbols += wordToString[index];
  44.                     }
  45.                     index++;
  46.                 }
  47.  
  48.                 symbols = symbols.ToUpper();
  49.                 //Console.WriteLine("SYMBOLS: {0}", symbols);
  50.                 //Console.WriteLine("NUMBER: {0}", number);
  51.  
  52.                 for (int i = 0; i < int.Parse(number); i++)
  53.                 {
  54.                     result.Append(symbols);
  55.  
  56.                     foreach (var symbol in symbols)
  57.                     {
  58.                         uniqueSymbols.Add(symbol);
  59.                     }
  60.                 }
  61.  
  62.                
  63.                // string wordpattern = "([^0-9])";
  64.  
  65.                // string[] bu = Regex.Split(word.ToString(), wordpattern);
  66.  
  67.                // Console.WriteLine("Bu: " + String.Join(" ", bu));
  68.                 /*foreach (var letter in bu)
  69.                 {
  70.  
  71.                     if (int.TryParse(letter, out digit))
  72.                     {
  73.                         digit = int.Parse(letter);
  74.                         if (digit <= 0)
  75.                         {
  76.                             continue;
  77.                         }
  78.                     }
  79.                     else
  80.                     {
  81.                         letters += letter.ToString().ToUpper();
  82.                     }
  83.                 }
  84.                 foreach (var g in letters)
  85.                 {
  86.                     if (!letterCounter.Contains(g) && !String.IsNullOrWhiteSpace(g.ToString()))
  87.                     {
  88.                         letterCounter += g;
  89.                     }
  90.                 }*/
  91.                 //dictLetterDigit.Add(letters, digit);
  92.             }
  93.             //Console.WriteLine(resylt);
  94.             Console.WriteLine("Unique symbols used: {0}", uniqueSymbols.Count());
  95.             Console.WriteLine(result);
  96.             /*foreach (var blabla in dictLetterDigit)
  97.             {
  98.                 for (int i = 0; i < blabla.Value; i++)
  99.                 {
  100.                     Console.Write(blabla.Key);
  101.                 }
  102.             }*/
  103.         }
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment