| Bytes | Lang | Time | Link |
|---|---|---|---|
| 012 | Uiua | 240601T104514Z | noodle p |
| 151 | Batch | 240715T163325Z | T3RR0R |
| 034 | sed | 240612T074603Z | Jan Blum |
| 050 | Google Sheets | 240531T205754Z | z.. |
| 040 | Zsh | 240603T101254Z | GammaFun |
| 050 | PowerShell Core | 240603T215033Z | Julian |
| 029 | J from Jsoftware | 240603T212625Z | scara95 |
| 019 | Perl 5 pF[^AEIOUaeiou] | 240603T140610Z | Xcali |
| 050 | Bash | 240603T100132Z | Themooni |
| 046 | jq | 240603T102035Z | GammaFun |
| 069 | Java JDK | 240603T091522Z | int 21h |
| 010 | Brachylog | 240603T081704Z | Fatalize |
| 107 | 05AB1E legacy | 240603T073239Z | Kevin Cr |
| 086 | C gcc | 240601T083520Z | Arnauld |
| 052 | R | 240601T120127Z | pajonk |
| 054 | Python | 240601T003957Z | Albert.L |
| 023 | AWK | 240601T215709Z | corvus_1 |
| 128 | Go | 240531T194424Z | bigyihsu |
| 004 | Japt v2.0a0 | 240531T204215Z | Shaggy |
| 030 | Scala 2 | 240601T190845Z | corvus_1 |
| 018 | Retina | 240531T225934Z | Neil |
| 076 | Python | 240531T211200Z | Sanguine |
| 047 | JavaScript ES6 | 240531T215706Z | Arnauld |
| 024 | Perl 5 lp | 240601T073227Z | Nahuel F |
| 034 | Arturo | 240601T054214Z | chunes |
| 017 | Uiua SBCS | 240601T044048Z | chunes |
| 003 | Vyxal 3 | 240601T001808Z | lyxal |
| 031 | Ruby | 240531T230230Z | Dingus |
| 014 | Charcoal | 240531T214235Z | Neil |
| 038 | APL+WIN | 240531T204216Z | Graham |
Uiua, 12 bytes
⊕□∈"AEIOU"⊸⌵
Try it: Uiua pad
⊕ group (with □ boxing) by whether each character ∊ is a member of "AEIOU" when ⊸⌵ uppercased.
Batch 151 bytes
@Echo off&Set $=For /f "Delims=" %%G in ('cmd.exe/u/c ^^^"Echo(%1^^^"^^^|find/v ""^^^|findstr/li# "a e i o u"'^)Do ^<nul Set/p=%%G
%$:#=%
Echo(
%$:#=V%
Input is as a parameter from the command line.
How: $ is defined with a macro that enacts tho following logic:
cmd.exe/u/c ^"Echo(%1^"^|find/v "" - Splits the stringt into individual characters
findstr/li# "a e i o u" - print characters matching aeiou if # has been removed during the macros expansion; or prints characters not matching aeiou if # has been substituted with V during expansion.
sed, 34 bytes
h
s/[^aeiou]//gi
p
g
s/[aeiou]//gi
Prints two strings on separate lines.
Bash (+sed), 37 bytes
p=aeiou]//gi
sed "h;s/[^$p;p;g;s/[$p"
Expands to equivalent of
Bash (+sed), 40 bytes
sed 'h
s/[^aeiou]//gi
p
g
s/[aeiou]//gi'
Google Sheets, 50 bytes
Assumes the string is in A1 and it returns the result in two horizontally adjacent cells.
=SORT(REGEXREPLACE(A1,"(?i)["&{"^",""}&"aeiou]",))
Demo
Zsh, 40 bytes
p=aeiouAEIOU
<<<${1//[^$p]}'
'${1//[$p]}
${1//PATTERN} removes all substrings matching PATTERN. The trailing/leading single quote is there to include a literal newline in the string which is printed.
Bash, 41 bytes
-1 byte thanks to @Themoonisacheese
Bash uses a different character for negation in character classes, and requires two more bytes for echo .... But, as @Themoonisacheese points out, the globbing character ] can be included in the parameter, which saves a byte.
p=aeiouAEIOU]
echo ${1//[!$p}'
'${1//[$p}
PowerShell Core, 50 bytes
$args|group{$_-in("aeiou"|% t*y)}|%{-join$_.Group}
Takes the input string using splatting
Returns two strings
$args # The string as chars
|group{$_-in("aeiou"|% t*y)} # Arranged in groups checking if each char is a vowel or not
|%{-join$_.Group} # Joined in a string for each group
J from Jsoftware, 29 bytes
(e.(#;]#~[=0:)[)&'aeiouAEIOU'
J from Jsoftware, 32 bytes
((e.#[);[#~0:=e.)&'aeiouAEIOU'
Bash, 50 bytes
-8 bytes using stdout, thanks GammaFunction
-1 byte with a better alias, by me
-6 bytes using <<< instead of echo , by me
-8 bytes by removing redundant grep call, which enables me to use a better alias, by me
g="grep -i [aeiou] "
$g-o<<<$1
grep -o .<<<$1|$g-v
use as a script or as the body of a bash function and call with input as first argument. Outputs vowels then consonnants, one per line.
See also: 42 bytes by GammaFunction.
jq, 46 bytes
./""|group_by(inside("aeiouAEIOU"))[]|join("")
group_by takes any filter, so we group by whether each character is inside the string of all vowels.
Java (JDK), 69 bytes
The solution is straightforward containing just two calls to the same method. Smarter would be of course to replace them with a loop like for(char j:{"","^"})r+=s.replaceAll("(?i)["+j+"aeiou]","") but I don't see how to overcome that verbosity ))
s->s.replaceAll("(?i)[^aeiou]","")+" "+s.replaceAll("(?i)[aeiou]","")
Brachylog, 10 bytes
{ḷ∈Ṿ|l}ᵍcᵐ
Explanation
{ }ᵍ Group by: group letters together if they give the same output
ḷ∈Ṿ The letter lowercased is in "aeiou", the output is then "aeiou"
| Else (the letter is a consonant)
l The output is the length of "aeiou" = 5
cᵐ Map concatenate to get 2 strings instead of lists of chars
05AB1E (legacy), 10 (or 7) bytes
žMžN‚Du+€Ã
Try it online or verify multiple test cases at once.
If outputting just a single group when the input only contains vowels or only consonants, it could be 7 bytes in the new version of 05AB1E with a group-by builtin:
.¡žMslå
Try it online or verify multiple test cases at once.
Explanation:
žM # Push the lowercase vowels constant excluding y
žN # Push the lowercase consonants constant including y
‚ # Pair the two together
D # Duplicate
u # Uppercase the strings in the copy
+ #†Element-wise append them
€ # Map over both strings:
à # Keep just those characters from the (implicit) input-string
# (after which the resulting pair is output implicitly)
†: This is the reason for the legacy version of 05AB1E, which is built in Python, where + can be used to append strings. Whereas in the new version of 05AB1E, built in Elixir, + is only used for numeric calculations.
.¡ # Group the characters in the (implicit) input by:
žM # Push the lowercase vowels constant excluding y
s # Swap so the current character is at the top of the stack
l # Convert it to lowercase
å # Check whether it's in the vowels constant
# (after which the list of lists of characters is output implicitly)
C (gcc), 86 bytes
Prints the consonants, followed by a space, followed by the vowels.
char*v,*q;f(char*s){for(q=v=s;*v=*s;)2130466>>*s++&1?v++:putchar(*v);printf(" %s",q);}
Method
We use 3 pointers:
sis the string pointer passed as input.vis a vowel pointer, less than or equal tos. At each iteration, we copy the character at*sto*v(including the trailing\0). Butvis incremented only when the copied character is a vowel, thus progressively overwriting the beginning of the original string with the vowels.qis just a copy of the original pointer. We use it to print all the vowels at once at the end of the process.
Vowels are identified with the following bitmask:
2130466 = 0b1000001000001000100010
^ ^ ^ ^ ^
u o i e a
It is assumed that only the 5 least significant bits of the shift amount are taken into account, which is the case for at least Intel and ARM.
R, 52 bytes
\(s,`?`=\(p)gsub(p,"",s,T))c(?"[^aeiou]",?"[aeiou]")
Explanation outline
- The idea is to replace all consonants (
[^aeiou]) and then all vowels ([aeiou]) with nothing. - For that we use
gsubwithignore.caseflag (4th argument) set toTrue. - We assign
gsubwith appropriate arguments to?for brevity, leaving onlypattern as argument.
Python, 54 bytes
lambda s:"".join(sorted(s+" ",key="aiueoAIUEO".count))
Returns a single string with the two parts separated by a space.
Python, 57 bytes (@Mukundan314)
o=2*[""]
for x in input():o[x in"aiueoAIUEO"]+=x
print(o)
Python, 58 bytes
o=["",""]
for x in input():o[x in"aiueoAIUEO"]+=x
print(o)
Full program.
Python, 66 bytes (@Mukundan314)
lambda s,v="aiueoAIUEO":[v:=[i for i in s if{i}-{*v}]for _ in"xx"]
Outputs lists of characters.
Python, 70 bytes
lambda s,v="aiueoAIUEO":[v:="".join(x.strip(v)for x in s)for _ in"xx"]
Python, 72 bytes
lambda s,v="aiueoAIUEO":[v:="".join(x*-v.find(x)for x in s)for _ in"xx"]
Python, 77 bytes
lambda s,v="aiueoAIUEO":[v:=s.translate({}.fromkeys(v.encode()))for _ in"xx"]
AWK, 23 bytes
Using flags -vIGNORECASE=1 -vRS=[aiueo]+.
{printf RT;printf$0>FS}
Prints vowels to stdout and consonants to a file called (single space).
Go, 132 128 bytes
import."strings"
func f(s string)(c,v string){for i:=range s{if r:=s[i:i+1];ContainsAny(r,"aeiouAEIOU"){v+=r}else{c+=r}}
return}
Loops over each character, checks to see if it is one of "aeiouAEIOU", and appends it to the corresponding output string.
c is the consonants, and v is the vowels.
- -4 by @Mukundan314 by just including the uppercase vowels
Japt v2.0a0, 4 bytes
üè\c
üè\c :Implicit input of string
ü :Group & sort by
è : Count of
\c : RegEx character class for consonants
Retina, 18 bytes
*\T`Vv`_
T`Vvp`Vv_
Try it online! Outputs the consonants followed by the vowels. Explanation:
*\`
Run the stage and print the results but don't save them, so the next stage uses the original input.
T`Vv`_
Delete all upper and lower case vowels from the input.
T`Vvp`Vv_
Keep all upper and lower case vowels but delete all other printable ASCII.
This would be a massive 48 bytes in Retina 0.8.2; you do at least save a byte by not needing the explicit \ after the * but Retina 0.8.2 doesn't have V or v so you need to use A\EI\OUaei\ou on the first line and A\EI\OUaeiou twice on the second (o does not need to be quoted if you use it on both sides).
Python, 79 78 76 bytes
-1 from me
-2 from solid.py!
lambda s,l='[aeiouAEIOU]':(sub('[^'+l[1:],'',s),sub(l,'',s))
from re import*
Saved a byte by modifying the regex instead of joining the array from .findall().
Original version (79 bytes)
from re import*
f=lambda s,l='[aeiouAEIOU]':(''.join(findall(l,s)),sub(l,'',s))
Returns a tuple including the vowel string and the consonant string.
JavaScript (ES6), 47 bytes
Returns [ consonants, vowels ].
s=>[s.replace(/[aeiou]/gi,c=>(v+=c,""),v=""),v]
Commented
s => [ // s = input string
s.replace( // replace in s:
/[aeiou]/gi, // look for all vowels, case insensitive
c => // for each vowel c:
( //
v += c, // append c to v
"" // remove it from the original string
), //
v = "" // start with v = ""
), // end of replace() -> only consonants remain
v // return the string of vowels in 2nd position
] //
Arturo, 34 bytes
$->s->@[--s<=match s{(?i)[aeiou]}]
Outputs a list where the first element is a list of vowels as singleton strings and the second element is a string of consonants.
Explanation
$->s-> ; function taking a string s
@[ ] ; capture the following in a list:
-- ; set difference between...
s ; input and...
<= ; extra copy of...
match s{(?i)[aeiou]} ; case-insensitive vowels in input
Uiua SBCS, 17 bytes
∩▽¬,,∊,⊂⌵."aeiou"
∩▽¬,,∊,⊂⌵."aeiou"
"aeiou" # the string 'aeiou'
⊂⌵. # duplicate, uppercase, prepend
∊, # mask of vowels w/ input
¬,, # mask of consonants w/ input
∩▽ # keep both
Vyxal 3, 3 bytes
⸠AĠ
Returns a list of [vowels, consonants]
Explained
⸠AĠ
Ġ # Split the input into groups based on whether
⸠A # Each character is a vowel
💎
Created with the help of Luminespire.
Ruby, 31 bytes
->s{[v=s.grep(/[aeiou]/i),s-v]}
Input as an array of characters, assumed to contain only uppercase and lowercase letters. Output is a two-element array of vowels followed by consonants, both as arrays of characters.
Charcoal, 14 bytes
E²Φθ⁼ι№aeiou↧λ
Try it online! Link is to verbose version of code. Outputs the consonants then vowels on separate lines. Explanation:
² Literal integer `2`
E Map over implicit range
θ Input string
Φ Filtered where
№ Count of
λ Current character
↧ Lowercased
aeiou In literal string `aeiou`
⁼ Equals
ι Outer value
Implicitly print
APL+WIN, 38 bytes
Prompts for word and outputs consonants followed by vowels in the order they appear in the word. Can be 4 bytes shorter if order does not matter.
(s~v),' ',v[((v←'AaEeIiOoUu')⍳s←⎕)~11]

