Guest User

Untitled

a guest
Feb 20th, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Winning_Ticket
  5. {
  6. class WinningTicket
  7. {
  8. static void Main(string[] args)
  9. {
  10. var inputTicket = Console.ReadLine().Split(new char[] { ' ', '\n', '\r', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  11.  
  12. for (int i = 0; i < inputTicket.Length; i++)
  13. {
  14. if (inputTicket[i].Length != 20)
  15. {
  16. Console.WriteLine("invalid ticket");
  17. }
  18. else
  19. if ((inputTicket[i].Contains("@")
  20. || inputTicket[i].Contains("#")
  21. || inputTicket[i].Contains("^")
  22. || inputTicket[i].Contains("$"))
  23. && inputTicket[i].Length == 20)
  24. {
  25.  
  26. var output = inputTicket[i].ToLower().Split(new char[] { ' ', ',', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }, StringSplitOptions.RemoveEmptyEntries).OrderByDescending(x => x).ToList();
  27.  
  28. //Console.WriteLine(string.Join(" ", output));// test -> th@@@@@@@emo@@@@@@ey - 6@
  29. // test -> @@th@@@@@@emo@@@@@@e - 6@
  30.  
  31. var symbol = string.Join("", output[0].ToCharArray().Take(1));
  32.  
  33. int count = output[0].Count();
  34.  
  35. if (output.Count > 1)
  36. {
  37. count = Math.Min(output[0].Count(), output[1].Count());
  38. }
  39.  
  40. if (count <= 9
  41. && count >= 6)
  42. {
  43. Console.WriteLine($"ticket \"{ inputTicket[i] }\" - {count}{symbol}");
  44. }
  45. if (count >= 10)
  46. {
  47. Console.WriteLine($"ticket \"{ inputTicket[i] }\" - 10{symbol} Jackpot!");
  48. }
  49.  
  50. if (count < 6)
  51. {
  52. Console.WriteLine($"ticket \"{ inputTicket[i] }\" - no match");
  53. }
  54. }
  55. else
  56. {
  57. Console.WriteLine($"ticket \"{ inputTicket[i] }\" - no match");
  58. }
  59. }
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment