Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Comments on Just the vowels please

Post

Just the vowels please

+4
−0

Given a sequence of letters, output only the vowels.

Input

  • A sequence of letters
  • This may be a string or any ordered data structure of characters (provided it is consistent between inputs)
  • The letters may contain a mixture of upper and lower case
  • The characters that count as letters for this challenge are A-Z and a-z, specifically ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
  • The input may be empty (it may have length zero)

Output

  • All of the vowels from the input, in the same order, and nothing else
  • This may be a string or any ordered data structure of characters. It does not need to match the input format (provided it is consistent between inputs)
    • For example, you may take input as an array of characters, and output as a string, provided this does not change for different inputs
  • Vowels that appear more than once in the input must appear the same number of times in the output
  • If there are no vowels in the input, the output is empty (a sequence of length zero)
  • The characters that count as vowels for this challenge are AEIOUaeiou
  • Case must be maintained - a vowel that is lower case in the input must be lower case in the output, and a vowel that is upper case in the input must be upper case in the output

Test cases

Test cases are in the format "input" : "output"

"" : ""
"q" : ""
"S" : ""
"Rhythm" : ""
"a" : "a"
"art" : "a"
"atr" : "a"
"rat" : "a"
"rta" : "a"
"tar" : "a"
"tra" : "a"
"emu" : "eu"
"eum" : "eu"
"meu" : "eu"
"mue" : "ue"
"uem" : "ue"
"ume" : "ue"
"AaeEIiOouU" : "AaeEIiOouU"
"aaaaaaaa" : "aaaaaaaa"
"bbbbbbbb" : ""
"abababab" : "aaaa"
"babababa" : "aaaa"
"aLtErNaTe" : "aEae"

Explanations are optional, but I'm more likely to upvote answers that have one.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Is `null` a valid output if there are no vowels? (2 comments)
Is `null` a valid output if there are no vowels?
Shaggy‭ wrote about 2 years ago

Is null a valid output if there are no vowels?

trichoplax‭ wrote about 2 years ago

Unless there's a default on Meta to allow null as a substitute for an empty string / empty data structure I'm going to say no.

I want the input and output formats to be as flexible as possible to keep the competition open to as many languages as possible (and so people can explore alternative approaches), but I think insisting on a consistent output format keeps it just restrictive enough. I'll edit the input and output sections to make this explicit.

I do think that keeping to the Meta defaults unless the challenge has good reason to override one of them is important, to avoid adding unnecessary complication. So if someone raises this on Meta and the community settles on accepting null in place of an empty string for challenges in general, I definitely won't override that for this challenge.