Forum

Post 26.11.2012   # 1
Subject Problem 100 - VowelCount

This is possibly the most underrated problem by contestants of all time. A multitude of the top-scoring contestants did quite a lot of mistakes here. They probably didn’t pay much attention to details since the problem is only worth 100 points.

It would appear that one of the most difficult things here is to notice that the English Latin alphabet has 6 vowels, unlike the Macedonian Cyrillic which has 5. Many contestants forgot the letter 'Y'.

public class VowelCount {
  public int count(String sentence) {
    int c = 0;
    char prev = ' ';
    sentence = sentence.toUpperCase();
    String s = "AEIOUY";
    for (int i = 0; i < sentence.length(); i++) {
      char cc = sentence.charAt(i);
      if (s.indexOf(cc) >= 0) {
        if (cc != prev) {
          c++;
        }
      }
      prev = cc;
    }
    return c;
  }
}

palikrushev is offline Reply

Please login to post reply.