blob: e514506919095c633b939f2ace7d7a55c671a367 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import java.util.Arrays;
public class Ch1 {
public static void main(String[] args) {
System.out.println(word_count(new String[]{"unicode", "xml", "raku", "perl"}));
System.out.println(word_count(new String[]{"the", "weekly", "challenge"}));
System.out.println(word_count(new String[]{"perl", "python", "postgres"}));
}
private static int word_count(String[] arr) {
return (int) Arrays.stream(arr)
.filter(s -> !s.isEmpty() &&
s.toLowerCase().matches("^[aeiou].*|.*[aeiou]$"))
.count();
}
}
|