Advertisement
Stan0033

Untitled

Aug 1st, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. namespace apps
  8. {
  9. class Program
  10. {
  11. static string Get() { return Console.ReadLine(); }
  12.  
  13.  
  14.  
  15.  
  16. static void Main()
  17. {
  18. // ticket
  19. string raw = Get();
  20. List<string> rawList = raw.Split(", ").ToList();
  21. string pattern = @"[A-Za-z]*(?<money>[$|@|#|^]{6,10})[A-Za-z]*[$|@|#|^]{6,10}[A-Za-z]*";
  22. //-------------------------------------------------------------------------------------------
  23. //-------------------------------------------------------------------------------------------
  24.  
  25. //-------------------------------------------------------------------------------------------
  26. //-------------------------------------------------------------------------------------------
  27. MatchCollection matches = Regex.Matches(raw, pattern);
  28. if (matches.Count == 0) { Console.WriteLine("ticket \"validticketnomatch:(\" - no match"); }
  29. else
  30. {
  31. for (int i =0; i <rawList.Count; i++)
  32. {
  33. Match m = Regex.Match(rawList[i], pattern);
  34.  
  35. if (Regex.IsMatch(rawList[i], pattern))
  36. {
  37. int len = m.Groups["money"].Length;
  38. string currencies = m.Groups["money"].ToString();
  39.  
  40. char currency = currencies[0];
  41. if (len == 10)
  42. {
  43. Console.WriteLine($"ticket \"{m}\" - {len}{currency} Jackpot!");
  44. }
  45. else
  46. {
  47. Console.WriteLine($"ticket \"{m}\" - {len}{currency}");
  48. }
  49. }
  50. else
  51. {
  52. Console.WriteLine("invalid ticket"); continue;
  53. }
  54. }
  55.  
  56.  
  57.  
  58.  
  59. }
  60.  
  61. }
  62.  
  63.  
  64. }// END MAIN
  65.  
  66. }
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement