Advertisement
North_Point

04 – Winning Ticket

Aug 10th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.53 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.  
  7. namespace _04.Winning_Ticket
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var input = Console.ReadLine().Split(new char[] { ',',}, StringSplitOptions.RemoveEmptyEntries).
  14.                 Select(x => x.Trim()).ToArray();
  15.  
  16.             foreach (var item in input)
  17.             {
  18.                 var symbolCnt = 0;
  19.                 var chechCnt = 0;
  20.  
  21.                 var symbol = 0;
  22.                 var chech = 0;
  23.  
  24.                 var symb = "";
  25.                 if (item.Length == 20)
  26.                 {
  27.                     for (int i = 0; i < item.Length / 2; i++)
  28.                     {
  29.                         if (item[i] == '@')
  30.                         {
  31.                             symb = "@";
  32.                             symbolCnt++;
  33.                             chechCnt++;
  34.                         }
  35.                         else if (item[i] == '#')
  36.                         {
  37.                             symb = "#";
  38.                             symbolCnt++;
  39.                             chechCnt++;
  40.                         }
  41.                         else if (item[i] == '$')
  42.                         {
  43.                             symb = "$";
  44.                             symbolCnt++;
  45.                             chechCnt++;
  46.                         }
  47.                         else if (item[i] == '^')
  48.                         {
  49.                             symb = "^";
  50.                             symbolCnt++;
  51.                             chechCnt++;
  52.                         }
  53.                     }
  54.                     for (int i = item.Length / 2 ; i < item.Length ; i++)
  55.                     {
  56.                         if (item[i] == '@')
  57.                         {
  58.                             symbol++;
  59.                             chech++;
  60.                         }
  61.                         else if (item[i] == '#')
  62.                         {
  63.                             symbol++;
  64.                             chech++;
  65.                         }
  66.                         else if (item[i] == '$')
  67.                         {
  68.                             symbol++;
  69.                             chech++;
  70.                         }
  71.                         else if (item[i] == '^')
  72.                         {
  73.                             symbol++;
  74.                             chech++;
  75.                         }
  76.                     }
  77.                     if (symbolCnt == chechCnt && chech == symbol)
  78.                     {
  79.                         if (Math.Min(chech,chechCnt) == 10)
  80.                         {
  81.                             Console.WriteLine("ticket \"{0}\" - {1}{2} Jackpot!", item, Math.Max(chechCnt, chech), symb);
  82.                         }
  83.                         else if ((chechCnt >= 6) && (chech >= 6))
  84.                         {
  85.                             Console.WriteLine("ticket \"{0}\" - {1}{2}", item, Math.Max(chechCnt, chech), symb);
  86.                         }
  87.                         else
  88.                         {
  89.                             Console.WriteLine("ticket \"{0}\" - no match",item);
  90.                         }
  91.                     }
  92.                     else
  93.                     {
  94.                         Console.WriteLine("ticket \"{0}\" - no match", item);
  95.                     }
  96.                 }
  97.                 else
  98.                 {
  99.                     Console.WriteLine("invalid ticket");
  100.                 }
  101.             }
  102.         }
  103.     }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement