# Hide and seek programming exercise

Hide and seek programming exercise.

This is a message from the smiling dwarves: Do you know the game “Hide and seek”? Glad that you do! We want to find the position of every vowel in a string. Write a function that does that. Thanks a bunch.

Example:
"Hello" =>[2,5]
"abc"=>[1]
"aaVzcy"=>[1,2,6]

You can scroll down for the solution of this coding problem.

public static int[] VowelIndices(string word)
{
//Nothing special hire.
//Lets make all the chars the same case
//for easier checking, using ToLower() on "word".
word = word.ToLower();
List<int> r = new List<int>();
//we need an array for saving the positions. I will use List.
for (int i = 1; i < word.Length+1; i++)
{
//This "||" is an OR operator. And that long if statement
//will determine if a char is a vowel or not.
if (word[i-1]== 'a' || word[i - 1] == 'e' || word[i - 1] == 'i' ||
word[i - 1] == 'o' || word[i - 1] == 'u' || word[i - 1] == 'y')
{
//and if it is, we will add it to the List.
}
}
//After we go through the hole string and get the positions
//of all the vowels we will use ToArray() on the List "r"
//and convert it to an array.
return r.ToArray();
//In the real world, the job of a software engineer often is like
//this programming exercise. Not very new, or entertaining.
//But it is still part of the job. So prepare for some boring and
//repetitive code.. Or choose very carefully your specialty.
//Don't be just another coder. Try to be unique or at least
//very rare. Maybe on 100 programmers there is like only 2 or 3
//physics specialist? What about combining accounting and
//software engendering? Or Psychology? Or music. Or any kind of
//art. Try to have plan earlier in your career.
}