Sample Problem: Counting Vowels
This is a walk-through sample problem showing how to use the site.
Each problem has a description and one or more examples. Wherever you see
(your_function)
is where you should insert your solution (either a dfn or tacit function). The problem description for this sample problem is:
Write an APL function to count the number of vowels (A, E, I, O, U) in an array consisting of uppercase letters (AβZ).
Some task descriptions include a hint suggesting one or more APL primitives:
π‘ Hint: The membership function XβY
could be helpful for this problem.
These may be helpful in solving the problem, but you donβt have to use them. Clicking on a primitive in the hint opens its documentation page.
Each problem ends with some example cases:
Examples:
The symbol
β
is the APL comment symbol. In some of the examples, we provide comments to give you more information about the problem:
(your_function) 'COOLAPL'
3
(your_function) '' β empty argument
0
(your_function) 'NVWLSHR' β no vowels here
0
You can use these as a basis for implementing your solution.
Some of the examples use "boxed display" to make the structure of the returned results clearer. Boxing is always enabled on TryAPL and can be enabled in your local APL Session with the
]Box
user command:β³Β¨β³4 1 1 2 1 2 3 1 2 3 4 ]Box on Was OFF β³Β¨β³4 βββ¬ββββ¬ββββββ¬ββββββββ β1β1 2β1 2 3β1 2 3 4β βββ΄ββββ΄ββββββ΄ββββββββ
Your code must run in a default Dyalog environment using
Here are a dfn and a tacit solution:(βML βIO)β1
. If you use other settings forβML
orβIO
, they must be local. If you don't know what that means, don't worry, it won't matter to you.{+/β΅β'AEIOU'} 'COOLAPL' β dfn 3 (+/ββ'AEIOU') 'COOLAPL' β tacit function 3
If you enter one of the above functions into the input field below and click ✔ Test, you'll see that they only pass the basic test cases. This is because they donβt 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.
your_function β
Try entering
{+/,β΅β'AEIOU'}
which handles all test cases.