Advertisement
tanya_zheleva

01

Jan 31st, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace ExamPreparation
  6. {
  7. class Startup
  8. {
  9. static void Main()
  10. {
  11. string[] firstTokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  12. string[] secondTokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  13.  
  14. int startCount = 0;
  15.  
  16. if (firstTokens.Length <= secondTokens.Length)
  17. {
  18. startCount = firstTokens.TakeWhile((element, index) => element == secondTokens[index]).Count();
  19. }
  20. else
  21. {
  22. startCount = secondTokens.TakeWhile((element, index) => element == firstTokens[index]).Count();
  23. }
  24.  
  25. Array.Reverse(firstTokens);
  26. Array.Reverse(secondTokens);
  27.  
  28. int endCount = 0;
  29.  
  30. if (firstTokens.Length <= secondTokens.Length)
  31. {
  32. endCount = firstTokens.TakeWhile((element, index) => element == secondTokens[index]).Count();
  33. }
  34. else
  35. {
  36. endCount = secondTokens.TakeWhile((element, index) => element == firstTokens[index]).Count();
  37. }
  38.  
  39. if (startCount >= endCount)
  40. {
  41. Console.WriteLine(startCount);
  42. }
  43. else
  44. {
  45. Console.WriteLine(endCount);
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement