Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
911
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. string myString = "1.In order to get a Disneyland ticket
  2. 2.that includes the new Star Wars land
  3. 3.you must stay at a Disney hotel
  4. 4.the night of or night before your visit.
  5. 5.Day passes without a hotel
  6. 6.reservation will be available after June 23";
  7.  
  8. public static void Main(string[] args)
  9. {
  10. int vowelCount = 2; // match words with 2 or more vowels
  11. int skipWord = 3; // Consider every 3rd word only
  12. int skipLine = 2; // Consider every 2nd line only
  13. int wordCount = 0;
  14. int lineCount = 0;
  15.  
  16. string myString = @"1.In order to get a Disneyland ticket
  17. 2.that includes the new Star Wars land
  18. 3.you must stay at a Disney hotel
  19. 4.the night of or night before your visit.
  20. 5.Day passes without a hotel
  21. 6.reservation will be available after June 23";";
  22.  
  23. List<string> myList = myString.Split(Environment.NewLine).ToList();
  24. List<string> lineWords = new List<string>();
  25. char[] vowels = {'a', 'e', 'i', 'o', 'u'};
  26.  
  27. for (int i = skipLine; i <= myList.Count; i += skipLine)
  28. {
  29. int origWordCount = wordCount;
  30. lineWords = myList[i - 1].Split(' ').ToList();
  31. for (int j = skipWord; j <= lineWords.Count; j += skipWord)
  32. {
  33. char[] wordArr = lineWords[j-1].ToLower().ToCharArray();
  34. int match = vowels.Intersect(wordArr).Count();
  35. if (match >= vowelCount)
  36. wordCount++;
  37. }
  38. if (wordCount > origWordCount)
  39. lineCount++;
  40. }
  41.  
  42. Console.WriteLine("WordCount : {0}, LineCount : {1}", wordCount, lineCount);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement