Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace WinnerTicket
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] inputString = Console.ReadLine().Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- for (int i = 0; i < inputString.Length; i++)
- {
- if (inputString[i].Length == 20)
- {
- InputPattern(inputString[i]);
- }
- else
- {
- Console.WriteLine($"invalid ticket");
- }
- }
- }
- static void InputPattern(string v)
- {
- string input = v;
- string pattern = @"([@]{6,10}|[#]{6,10}|[$]{6,10}|[\^]{6,10})[A-Za-z0-9]*([@]{6,10}|[#]{6,10}|[$]{6,10}|[\^]{6,10})";
- Match match = Regex.Match(input, pattern);
- string b = match.Groups[1].ToString();
- string a = match.Groups[2].ToString();
- if (b.Length >= 6 && b.Length <= 10)
- {
- if (b.Length == 10 && a.Length == 10)
- {
- string symbol = b.Substring(1, 1);
- string symbol1 = a.Substring(1, 1);
- if (symbol == symbol1)
- {
- Console.WriteLine($"ticket \"{input}\" - {b.Length}{symbol} Jackpot!");
- return;
- }
- }
- else
- {
- string symbol = b.Substring(1, 1);
- string symbol1 = a.Substring(1, 1);
- if (symbol == symbol1)
- {
- int len = Math.Min(a.Length, b.Length);
- Console.WriteLine($"ticket \"{input}\" - {len}{symbol}");
- return;
- }
- }
- }else
- {
- Console.WriteLine($"ticket \"{input}\" - no match");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement