| Bytes | Lang | Time | Link |
|---|---|---|---|
| 102 | JavaScript Node.js | 241219T180750Z | l4m2 |
| 074 | Perl 5 MListUtil=uniq n | 241219T195725Z | Xcali |
| 019 | Japt v2.0a0 R | 180902T175902Z | Shaggy |
| 184 | Java OpenJDK 8 | 180904T152047Z | Roberto |
| 188 | Java 10 | 180903T094552Z | Kevin Cr |
| 129 | R | 180903T135901Z | digEmAll |
| 229 | Red | 180903T134814Z | Galen Iv |
| 019 | 05AB1E legacy | 180902T213853Z | Mr. Xcod |
| 064 | Perl 6 | 180903T103355Z | nwellnho |
| 099 | JavaScript Node.js | 180902T204845Z | Arnauld |
| 112 | Python | 180902T175658Z | DimChtz |
| 112 | Python 2 | 180902T214138Z | Chas Bro |
| 096 | bash | 180902T211702Z | Doorknob |
| 017 | Jelly | 180902T192921Z | Jonathan |
| 045 | Retina | 180902T184343Z | Neil |
| 078 | Ruby | 180902T182233Z | Kirill L |
JavaScript (Node.js), 102 bytes
s=>'aeiou'.replace(r=/[aeiou]/ig,(c,j)=>s.match(c+'|'+(w='AEIOU'[j]))?s.replace(r,d=>d<{}?w:c)+`
`:'')
Perl 5 MList::Util=uniq -n, 74 bytes
@;=uniq lc=~/[aeiou]/ig;s/[aeiou]/$b/g&s/[AEIOU]/\U$b/g&say while$b=shift@
Y is not a vowel in this implementation.
Japt v2.0a0 -R, 24 22 19 bytes
Treats y as a vowel. Change both occurences of \y to \v to treat it as a consonant.
f\y â £r\y_¶u ?X:Xv
f\y â £r\y_¶u ?X:Xv :Implicit input of string U
f :Matches of
\y : RegEx /[aeiouy]/gi (\v is /[aeiou]/gi)
â :Deduplicate
£ :Map each X
r\y : Replace /[aeiouy]/gi in U
_ : Pass each match through the following function
¶ : Is equal to
u : Itself uppercased
?X : If true return X
:Xv : Else return X lowercased
Java (OpenJDK 8), 184 bytes
y is a vowel
s->s.chars().mapToObj(c->""+(char)(c>96?c:c+32)).filter("aeiouy"::contains).distinct().forEach(c->System.out.println(s.replaceAll("[aeiouy]",c).replaceAll("[AEIOUY]",c.toUpperCase())))
Java 10, 196 188 bytes
s->{var d=new int[99];for(var c:s.toUpperCase().replaceAll("[^AEIOU]","").toCharArray())if(d[c]++<1)System.out.println(s.replaceAll("[AEIOU]",c+"").replaceAll("[aeiou]",(char)(c+32)+""));}
-8 bytes thanks to @joH1.
Without y as vowel to save bytes.
Explanation:
s->{ // Method with String parameter and no return-type
var d=new int[99]; // Integer-array indicating which vowels we've already output
for(var c:s.toUpperCase()// Convert the input to uppercase
.replaceAll("[^AEIOU]","")
// Remove all non-vowels
.toCharArray())// Convert it to a character array)
// And loop over those vowel-characters
if(d[c]++ // Increase the vowel-count by 1
<1) // And if it was 0 this iteration:
System.out.println( // Print with trailing newline:
s // The input,
.replaceAll("[AEIOU]",c+"")
// with every uppercase vowel replace with the current vowel
.replaceAll("[aeiou]",(char)(c+32)+""));}
// and every lowercase vowel replaced as well
R, 138, 129 bytes
function(x,U=utf8ToInt,a=U(V<-'aeiouAEIOU'))for(i in (which(a%in%U(x))-1)%%5)cat(chartr(V,intToUtf8(rep(a[i+c(1,6)],e=5)),x),'
')
yis not considered a vowel
Red, 229 bytes
Taking y for a non-vowel
func[s][v: charset"aoeiu"w: charset"AOEIU"p: copy""parse s[any[[copy c[v | w](if not find p c[append p c lowercase c
parse s[any[[copy n to[v | w | end]](prin n)opt[v(prin c)|[w(prin uppercase copy c)]| skip]]]print""])]| skip]]]
Slightly more readable:
f: func [ s ] [
v: charset "aoeiu"
w: charset "AOEIU"
p: copy ""
parse s[
any [
[ copy c [ v | w ]
( if not find p c [
append p c
lowercase c
parse s [
any [
[ copy n to [ v | w | end ] ]
( prin n )
opt [ v ( prin c )
| [ w ( prin uppercase copy c ) ]
| skip
]
]
]
print ""
] )
]
| skip
]
]
]
05AB1E (legacy), 19 bytes
(Indirectly) saved one byte thanks to Kevin (printing directly inside the loop rather than joining, only work in the legacy version).
lžMÃÙεžMDu«s5×Du«‡=
Using the Elixir rewrite, 20 bytes
lžMÃÙεžMDu«s5×Du«‡}»
Try it online! (without y) | Try it online! (with y, žM being replaced by žO – same applies for the legacy version)
How it works
lžMÃÙεžMDu«s5×Du«‡}» Full program. Example: "Hello"
l Convert the input to lowercase. "Hello" –> "hello"
žMÃ Keep only lowercase vowels. "hello" –> "eo"
Ù Remove duplicates. "eo" –> "eo"
ε } For each of the characters (example with "e"):
žMDu« Yield "aeiouAEIOU"
s5× Swap, and repeat the current char 5 times. "e" –> "eeeee"
Du« Duplicate, uppercase and merge. "eeeee" –> "eeeeeEEEE"
‡ Transliteration. For each item in B, replace it in A with
the corresponding item in C.
» Join on newlines.
JavaScript (Node.js), 99 bytes
Treats \$y\$ as a consonant.
s=>(g=F=>Buffer(s).map(c=>2130466>>c&c>64?F(c):c)+`
`)(v=>g[v&=31]||(g[v]=S+=g(c=>c&96|v)),S='')&&S
Commented
s => ( // s = input string
g = F => // g = helper function taking a callback function F
Buffer(s) // turn s into a Buffer
.map(c => // for each ASCII code c in s:
2130466 // 2130466 is a vowel bitmask: 1000001000001000100010
// u o i e a
>> c // the ECMAScript specification enforces that the shiftCount is
// the result of masking out all but the least significant 5 bits
& c > 64 // also make sure to ignore non-letter characters
? // if a vowel is identified:
F(c) // invoke F with c
: // else:
c // just yield c
) + `\n` // end of map(); coerce back to a string and append a newline
)(v => // invoke g with a callback that takes v:
g[v &= 31] || ( // unless this vowel has already been encountered:
g[v] = // mark it as encountered
S += // and append to the output string S
g( // the result of another call to g:
c => c & 96 | v // where vowels are replaced with v, using the original case
) // end of inner call to g
), //
S = '' // start with S = ''
) && S // end of outer call to g; return S
Python, 129 119 112 bytes
import re
f=lambda s:'\n'.join(r('[AEIOU]',v.upper(),r('[aeiou]',v,s))for v in'aeiou'if v in s.lower());r=re.sub
Doesn't treat \$y\$ as vowel.
-7 bytes thanks to @Mr.Xcoder
Python 2, 112 bytes
s=input()
V='aeiouAEIOU'
for v in V:
if v in s.lower():print''.join([c,[v.upper(),v][c>'Z']][c in V]for c in s)
Treats y as a consonant.
bash, 96 bytes
Two equal-length solutions:
v=aeiouAEIOU;for x in `grep -o [$v]<<<$1|sed 's/./\L&&&&&\U&/'|awk !a[\\$0]++`;{ tr $v $x<<<$1;}
v=aeiouAEIOU;for x in `tr -cd $v<<<$1|sed 's/./\L&&&&&\U&\n/g'|awk !a[\\$0]++`;{ tr $v $x<<<$1;}
Takes input as a command line argument and outputs to STDOUT.
Jelly, 23 20 18 17 bytes
-2 Thanks to Erik the Outgolfer
ØcŒHZx5fƇðØc,yð€Y
To treat y as a vowel replace both cs with ys.
How?
ØcŒHZx5fƇðØc,yð€Y - Link: list of characters, S
Øc - vowels -> "AEIOUaeiou"
ŒH - split in half -> ["AEIOU", "aeiou"]
Z - transpose -> ["Aa", "Ee", "Ii", "Oo", "Uu"]
x5 - times 5 -> ["AAAAAaaaaa", "EEEEEeeeee", "IIIIIiiiii", "OOOOOooooo", "UUUUUuuuuu"]
Ƈ - filter keep if:
f - filter keep only -> those of X which have required vowels
- ...i.e. if S = "blah" then ["AAAAAaaaaa"]
ð ð€ - dyadic chain for €ach:
Øc - vowels -> "AEIOUaeiou"
, - pair e.g. ["AEIOUaeiou","AAAAAaaaaa"]
y - translate e.g. swap A for A, E for A, ...
Y - join with newlines
Retina, 45 bytes
~(K`A\EI\OU
L$`\\?(.)
./$1/i&$*\T`Vv`5*$&$L$&
Try it online! Does not count y as a vowel. Explanation:
K`A\EI\OU
Replaces the text with the literal string A\EI\OU.
L$`\\?(.)
Matches each letter optionally preceded by a backslash.
./$1/i&$*\T`Vv`5*$&$L$&
Outputs a line of Retina code for each letter.
~(
Evaluates the generated code (shown below) using the original input. The . causes the code not to output the (final) buffer. The /<vowel>/i& causes the rest of the line to run only if the input contains the given vowel (case-insensitively). The * causes the result of the line to be ignored, so that the next vowel can be tested. The \ causes the result to be printed on its own line before it is ignored. The T`Vv`AAAAAa transliterates uppercase Vowels to AAAAAs and all lowercase vowels to a. \A is an escape that refers to ASCII 07 (BEL), but E, O and o are built-in character classes that needs to be escaped to give their literal values (e is not a character class, but fortunately it is also not an escape.)
./A/i&*\T`Vv`AAAAAa
./E/i&*\T`Vv`\E\E\E\E\E\e
./I/i&*\T`Vv`IIIIIi
./O/i&*\T`Vv`\O\O\O\O\O\o
./U/i&*\T`Vv`UUUUUu
Ruby, 78 bytes
->s{s.downcase.scan(/[aeiou]/).uniq.map{|v|s.tr"AEIOUaeiou",v.upcase*5+v}*?\n}
A quick and naive approach. Y is not considered a vowel.