Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Numerics;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace apps
- {
- class Program
- {
- static string Get() { return Console.ReadLine(); }
- static void Main()
- {
- // ticket
- string raw = Get();
- List<string> rawList = raw.Split(", ").ToList();
- string pattern = @"[A-Za-z]*(?<money>[$|@|#|^]{6,10})[A-Za-z]*[$|@|#|^]{6,10}[A-Za-z]*";
- //-------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------
- MatchCollection matches = Regex.Matches(raw, pattern);
- if (matches.Count == 0) { Console.WriteLine("ticket \"validticketnomatch:(\" - no match"); }
- else
- {
- for (int i =0; i <rawList.Count; i++)
- {
- Match m = Regex.Match(rawList[i], pattern);
- if (Regex.IsMatch(rawList[i], pattern))
- {
- int len = m.Groups["money"].Length;
- string currencies = m.Groups["money"].ToString();
- char currency = currencies[0];
- if (len == 10)
- {
- Console.WriteLine($"ticket \"{m}\" - {len}{currency} Jackpot!");
- }
- else
- {
- Console.WriteLine($"ticket \"{m}\" - {len}{currency}");
- }
- }
- else
- {
- Console.WriteLine("invalid ticket"); continue;
- }
- }
- }
- }
- }// END MAIN
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement