This site automatically validates APL solutions for practice problems sourced from The APL Problem Solving Competition’s phase 1.
Each problem starts with a task description; some also include a hint suggesting one or more APL primitives. These may be helpful in solving the problem, but you are under no obligation to use them. Clicking on a primitive in the hint opens the Dyalog documentation page for that primitive.
Each problem ends with some example cases. You can use these as a basis for implementing your solution.
Notice something wrong? Report a bug.
Every problem has one or more solutions explained fully in the APL Quest video series.
Write an APL function to count the number of vowels (A, E, I, O, U) in an array consisting of uppercase letters (A–Z).
💡 Hint: The membership function X∊Y
could be helpful for this problem.
Examples
(your_function) 'COOLAPL'
3
(your_function) '' ⍝ empty argument
0
(your_function) 'NVWLSHR' ⍝ no vowels here
0
Below are three sample solutions. All three produce the correct answer, but the first twofunctions would be ranked higher by the competition judging committee. This is becausethe first two demonstrate better use of array-oriented programming.
({+/⍵∊'AEIOU'}) 'COOLAPL' ⍝ good dfn
3
(+/∊∘'AEIOU') 'COOLAPL' ⍝ good tacit function
3
{(+/⍵='A')+(+/⍵='E')+(+/⍵='I')+(+/⍵='O')+(+/⍵='U')} 'COOLAPL' ⍝ suboptimal dfn
3
If you put each of the above three functions into the input field below and click Submit, you’ll see that they only pass the basic test cases. This is because none of those functions handle arrays with 2 or more dimensions. The system will also give you an example of a multi-dimensional edge case that failed, so that you can attempt to improve your solution.
Try entering {+/,⍵∊'AEIOU'}
which handles all test cases.