Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string myString = "1.In order to get a Disneyland ticket
- 2.that includes the new Star Wars land
- 3.you must stay at a Disney hotel
- 4.the night of or night before your visit.
- 5.Day passes without a hotel
- 6.reservation will be available after June 23";
- public static void Main(string[] args)
- {
- int vowelCount = 2; // match words with 2 or more vowels
- int skipWord = 3; // Consider every 3rd word only
- int skipLine = 2; // Consider every 2nd line only
- int wordCount = 0;
- int lineCount = 0;
- string myString = @"1.In order to get a Disneyland ticket
- 2.that includes the new Star Wars land
- 3.you must stay at a Disney hotel
- 4.the night of or night before your visit.
- 5.Day passes without a hotel
- 6.reservation will be available after June 23";";
- List<string> myList = myString.Split(Environment.NewLine).ToList();
- List<string> lineWords = new List<string>();
- char[] vowels = {'a', 'e', 'i', 'o', 'u'};
- for (int i = skipLine; i <= myList.Count; i += skipLine)
- {
- int origWordCount = wordCount;
- lineWords = myList[i - 1].Split(' ').ToList();
- for (int j = skipWord; j <= lineWords.Count; j += skipWord)
- {
- char[] wordArr = lineWords[j-1].ToLower().ToCharArray();
- int match = vowels.Intersect(wordArr).Count();
- if (match >= vowelCount)
- wordCount++;
- }
- if (wordCount > origWordCount)
- lineCount++;
- }
- Console.WriteLine("WordCount : {0}, LineCount : {1}", wordCount, lineCount);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement