# Ot wes thi bist uf tomis

I just love this simple cypher, it's so fun reading not-quite human-readable words and filling the gaps...

Ot wes thi bist uf tomis, ot wes thi wurst uf tomis,
ot wes thi egi uf wosdum, ot wes thi egi uf fuuloshniss,
ot wes thi ipuch uf biloif, ot wes thi ipuch uf oncridaloty,
ot wes thi siesun uf loght, ot wes thi siesun uf derkniss,
ot wes thi sprong uf hupi, ot wes thi wontir uf dispeor,
wi hed ivirythong bifuri as, wi hed nuthong bifuri as,
wi wiri ell guong dorict tu hievin, wi wiri ell guong dorict thi uthir wey –
on shurt, thi piroud wes su fer loki thi prisint piroud,
thet sumi uf ots nuosoist eathurotois onsostid un ots biong riciovid,
fur guud ur fur ivol, on thi sapirletovi digrii uf cumperosun unly.


The rules are super-simple:

• Accept some text as input (ascii characters, upper/lower case letters and punctuation).
• For each vowel, rotate it to the next vowel, or back to the start.
• a => e
• e => i
• i => o
• o => u
• u => a
• Upper case vowels stay upper case, lower case vowels stay lower case.
• Output the text after these conversions.
• No need to support accents.
• The all other characters should remain unchanged.
• Try to do it in the smallest number of bytes.
• Any old language you like.

## Test Cases

It was the best of times, it was the worst of times,
it was the age of wisdom, it was the age of foolishness,
it was the epoch of belief, it was the epoch of incredulity,
it was the season of light, it was the season of darkness,
it was the spring of hope, it was the winter of despair,
we were all going direct to heaven, we were all going direct the other way –
in short, the period was so far like the present period,
that some of its noisiest authorities insisted on its being received,
for good or for evil, in the superlative degree of comparison only.


Out:

Ot wes thi bist uf tomis, ot wes thi wurst uf tomis,
ot wes thi egi uf wosdum, ot wes thi egi uf fuuloshniss,
ot wes thi ipuch uf biloif, ot wes thi ipuch uf oncridaloty,
ot wes thi siesun uf loght, ot wes thi siesun uf derkniss,
ot wes thi sprong uf hupi, ot wes thi wontir uf dispeor,
wi hed ivirythong bifuri as, wi hed nuthong bifuri as,
wi wiri ell guong dorict tu hievin, wi wiri ell guong dorict thi uthir wey –
on shurt, thi piroud wes su fer loki thi prisint piroud,
thet sumi uf ots nuosoist eathurotois onsostid un ots biong riciovid,
fur guud ur fur ivol, on thi sapirletovi digrii uf cumperosun unly.


In:

The quick brown fox jumps over the lazy dog.


Out:

Thi qaock bruwn fux jamps uvir thi lezy dug.


In:

Home is where the heart is.


Out:

Humi os whiri thi hiert os.


In:

Boaty McBoatface


Out:

Buety McBuetfeci


In:

AEIOUaeiou


Out:

EIOUAeioua


In:

Programming Puzzles And Code Golf


Out:

Prugremmong Pazzlis End Cudi Gulf

• A.k.a. The Great Vowel Shift
– Angs
Apr 23 '18 at 18:27
• Hmm. Olde English? Apr 24 '18 at 1:26
• Still an easier read than Beowulf. Apr 24 '18 at 10:50
• Looks like a kiwi-translater to me. Apr 24 '18 at 16:30
• I like how “evil” when ciphers to “ivol”, is effectively pronounced the same way. May 3 '18 at 6:34

# MS-SQL, 51 Bytes

Works on SQL 2017 or above:

SELECT TRANSLATE(v,'AEIOUaeiou','EIOUAeioua')FROM t


The new function TRANSLATE performs individual character replacement, so is ideally suited for this challenge.

Input is via a pre-existing table t with varchar column v, per our IO rules.

In this case the table must be created using a case-sensitive collation, either by running on a case-sensitive server, or by using the COLLATE keyword (not counted toward character total):

CREATE TABLE t(v varchar(max) COLLATE Latin1_General_CS_AS)


EDIT: SSMS may cut off the lengthy quote above when returning the result in a "results to text" window, this is a client setting, not a bug in my program.

To fix, go to Tools > Options > Query Results > SQL Server > Results to Text and increase the "Maximum number of characters displayed in each column."

• I'm genuinely shocked that SQL is even close to competitive for this. Also, that's a cool function! Thanks for telling us :)
– Nic
Apr 25 '18 at 14:40
• @NicHartley Yeah, they seem to add a couple useful functions each version. You can nest it with REPLACE for some tricks as well: REPLACE(TRANSLATE(v,'1234567890','xxxxxxxxxx'),'x','') to eliminate all numerals from a string, for example. Still long, but much shorter than 10 nested REPLACEs. Apr 25 '18 at 15:44

# Bash + coreutils, 24

tr aeiouAEIOU eiouaEIOUA


Try it online!

(a:b)!c|a/=c=b!c|1>0=b!!0
a!b=b
map("aeiouaAEIOUA"!)


Try it online!

Lynn saved me two bytes by pointing out that !!0 is shorter than head.

## Explanation

If you have never coded in Haskell this will probably look like a pile of jibberish. So first let's ungolf it and then break it down:

(a:b)!c
|   a/=c   = b!c
|otherwise = b!!0
a!b=b
map("aeiouaAEIOUA"!)


First we have a function !, which takes a string s and a character c. Our first pattern match catches accepts input if the string is non-empty. If the string is non-empty we compare its first character to c. If it's first character is not equal to c we toss it and call ! again with the remainder of the string and c. If it is equal we return the second character in the string.

Our next pattern match catches the string in all other cases, that is if the string is empty. In this case we just return c.

All in all this function takes a character c and a string s and returns the character after the first occurrence of c in s. If we pass this with aeiouaAEIOUA it will perform our cipher on a single character. To make our whole function we ought to map this across the string.

# Stax, 7 bytes

öΦΣòC└∞


Run and debug it

Try it online!

Explanation (unpacked)

Vv:tVV:t
Vv:t           #Push aeiou and ring translate it to input
VV:t       #Push AEIOU and ring translate it to input


Might be able to save more, will keep trying.

# Retina, 109 8 bytes

TuovVA


Try it online!

Saved 1 byte thanks to Neil! And another byte thanks to Martin!

The new version of retina has vowel classes, which makes the result a bit shorter. The transliteration also makes use of the "other" class. So the to class looks like "aeiouAEIOUA" while the from class looks like "uaeiouAEIOUA"

This doesn't cause any problems since the second u mapping to A will never be done since u was already mapped to a.

• 9 bytes: T_ouvUV.
– Neil
Apr 23 '18 at 15:25
• This is a remarkably short answer! Apr 23 '18 at 15:25
• @Neil clever, thanks! I thought putting an _ in the from set would treat it literally, but it looks like it doesn't do that. Apr 23 '18 at 15:31
• You can shave off one more, but I can't seem to tie Stax, unfortunately: tio.run/##HYnBDoIwEAXv/… Apr 23 '18 at 22:26
• @MartinEnder Thanks! That's a clever setup, mixing between the two. I haven't tried using Y much yet so I'll give that a shot tomorrow. Apr 24 '18 at 5:12

# Perl 5 + -p, 24 23 bytes

y;AEIOUaeiou;EIOUAeioua


Try it online

-1 byte thanks to @DomHastings

• We don't count -p as +1 anymore, instead we consider that this answer is in "Perl 5 + -p". Apr 23 '18 at 15:14
• This also works in sed Apr 23 '18 at 18:19
• If you use ; as the delimiter you can save a byte! Apr 23 '18 at 19:08
• updated, @Cowsquack not anymore Apr 24 '18 at 7:38

# C, 85766765 64 bytes

f(char*c){for(;*c;)putchar(1[index("AEIOUAaeioua",*c++)?:c-2]);}


Port of Kevin Cruijssen's Java answer. Try it online here.

Thanks to Kevin Cruijssen for golfing 9 bytes, to Christoph for golfing 11 bytes and to ceilingcat for golfing 1 byte.

Ungolfed version:

f(char* c) { // function taking a char array as parameter and implicitly returning an unused int
for(; *c ;) // loop over the input
putchar(1 [index("AEIOUAaeioua", * c++) ?: c-2]); // find the first pointer to the current char in the vowels string, NULL if not present; if it's not NULL, print the next vowel, otherwise just print the char
}

• Seems to be a none standard extension from gcc. I knew it from php and simply tried it. Apr 24 '18 at 14:14
• @Christoph I like your use of recursion, but I'm not sure we can output a trailing \0. Also, this does not work when compiled with clang: tio.run/##S9ZNzknMS///… Apr 25 '18 at 8:20
• @Christoph: I was curious where the undefined behaviour was, so I debugged the clang version, after ungolfing it some more. const char *res = strchr("AEIOU...", 0) returns a pointer to terminator in the string literal. putchar(res[1]) reads past the end of the string literal. With gcc it apparently happens to find another zero byte and it happens to work, but with clang it gets a 73 'I' (probably from main's string literal, "It was...", but I didn't check the asm). So putchar doesn't return 0, and we eventually segfault when *c++ reads an unmapped page. Apr 25 '18 at 9:14
• @PeterCordes yeah I found out about it here after having a suspicion. Anyway here another 2 bytes saved f(char*c){for(;*c;)putchar(1[strchr("AEIOUAaeioua",*c++)?:c-2]);}. That's all for now I guess. Apr 25 '18 at 9:31
• @Rogem Because of the commutative property of addition, a[b]==*(a+b)==*(b+a)==b[a]. Therefore 1[...]==(...)[1] Aug 2 '18 at 22:27

# Python 3, 62 59 bytes

lambda x:x.translate(dict(zip(b'aeiouAEIOU','eiouaEIOUA')))


Make a translation table (dictionary) with str's static str.maketrans method. Translate relevant characters to their destination character.

EDIT: Saved 3 bytes by using the dict constructor to make the translation table instead of the str#maketrans method

• Where does this perform I/O? Apr 24 '18 at 14:42
• @reinierpost It's a function. The input is via the x parameter. In python, lambda functions don't need a return statement. Apr 24 '18 at 16:04

# R, 43 bytes

chartr("AEIOUaeiou","EIOUAeioua",scan(,""))


Try it online!

Here's my solution wrapped in a cat to get it to print out more nicely: Try it online!

# Jelly, 11 bytes

Øcs5ṙ€-Ẏ,Ʋy


Try it online!

# Python 2, 7968 67 bytes

-1 byte thanks to @ArnoldPalmer

V='uaeiouAEIOUA'
print''.join((V[1:]+c)[V.find(c)]for c in input())


Try it online!

• 67 bytes. Also, sorry if you got flooded with notifications, I haven't posted a comment in a while and forgot how to do it. Apr 24 '18 at 3:10
• @ArnoldPalmer Thanks! It's ok, I was away and they all missed me :D Apr 24 '18 at 9:55

# JavaScript (ES6), 60 bytes

s=>s.replace(/./g,c=>(S='aeiouaAEIOUA'+c+c)[S.indexOf(c)+1])


Try it online!

• s=>s.replace(/./g,c=>'auoieaAUOIEA'.match(".(?=${c})")||c) – tsh Apr 24 '18 at 6:34 • Error: only. => unlya – l4m2 Apr 25 '18 at 1:36 # Ruby-p, 31 bytes $_.tr!"AEIOUaeiou","EIOUAeioua"


Try it online!

# Pyth, 17 bytes

em=.rQdrB"aeiou"1


Try it here

em=.rQdrB"aeiou"1
m                  For each string...
rB"aeiou"1   ... in ['aeiou', 'AEIOU']...
=.rQd             ... cyclically rotate the characters in the input.
e                   Take the last.


# Japt 2.0, 25 21 bytes

I had fun golfing this one with Shaggy.

r\v@=aeiapu)g1+UbX


Run it here.

• 23 bytes Apr 23 '18 at 17:10
• @Shaggy That doesn't work with capital vowels. Apr 23 '18 at 17:37
• In that case ... 22 bytes. Apr 23 '18 at 18:09
• @Shaggy This is fun...21 bytes Apr 23 '18 at 18:21
• Nice! I think that's the first time I've seen S.p(f) used. Apr 23 '18 at 18:26

# Java 10, 97 87 bytes

s->{for(var c:s){var t="AEIOUAaeioua"+c+c;System.out.print(t.charAt(t.indexOf(c)+1));}}


-10 bytes after being inspired by @Arnauld's JavaScript answer (his 60-bytes version).

Try it online.

Explanation:

s->{                         // Method with character-array parameter and no return-type
for(var c:s){              //  Loop over the input characters
var t="AEIOUAaeioua"     //  Temp-String containing the order of vowels
//  (including additional 'A' and 'a'),
+c+c;              //  appended with two times the current character
System.out.print(        //  Print:
t.charAt(              //   The character in String t at index:
t.indexOf(c)+1));}} //    The (first) index of the current character in t + 1


# 05AB1E, 1413 11 bytes

žMDÀ‡žMuDÀ‡


Try it online!

• You can save two bytes by simply taking the input as a multi-line string, so there is no need for the | and »: Try it online: 11 bytes. Aug 2 '18 at 14:12
• @KevinCruijssen Thanks ! Isn't that something that was fixed in a recent 05AB1E release ? Aug 2 '18 at 14:39
• No idea tbh. Only started 05AB1E since about the start of this year. You could ask @Adnan in the 05AB1E chat when the feature was added if you want to know. Aug 2 '18 at 14:41

# Retina 0.8.2, 20 bytes

T_oA\EI\OUAaei\oua


Try it online! Link includes test cases.

# APL+WIN, 55 bytes

Prompts for input string:

i←(10≥n←'AEIOUaeiou'⍳s)/⍳⍴s←⎕⋄s[i]←'EIOUAeioua'[n~11]⋄s


# Mumps, 38 bytes

R T W $TR(T,"AEIOUaeiou","EIOUAeioua")  Mumps doesn't normally add a carriage return, as I didn't see a requirement to separate input from output it does look a bit weird on first run. For example, the output for the last test case looks like this: Programming Puzzles And Code GolfPrugremmong Pazzlis End Cudi Gulf  If you did want to add a carriage return, add two bytes thusly: R T W !,$TR(T,"AEIOUaeiou","EIOUAeioua")


# Vim + tpope/vim-abolish, 30 bytes

:%S/{a,e,i,o,u}/{e,i,o,u,a}/g<cr>


Alternate solution, also 30 bytes:

Oe,i,o,u<esc>|D:%s/{a,<C-r>"}/{<C-r>",a}/g


According to meta, vim answers can use plugins with no byte penalty. This is not a vim answer, but a vim + abolish answer.

Abolish is an extremely useful plugin. This section of the README nicely describes how this command (the Subvert command) works.

# CJam, 29 19 bytes

q"aeioua"_eu+_1m<er


Try it online!

-10 bytes thanks to @Peter Taylor

Explanation:

q                       # take all input
"aeioua"               # push vowel pairs
_eu            # duplicate, uppercase
+_          # concatenate, duplicate again
1m<       # rotate left by 1
er     # transliterate

• Although the question isn't specific about the input, I think you should probably use q rather than l to take input. The first test case appears to be multi-line. Also you can shorten "eioua" to _1m<. In fact, you can go further and golf this to q"aeioua"_eu+_1m<er Apr 23 '18 at 21:07

# AutoHotkey, 24 bytes

AuotHotkey automatically replaces letters in a case sensitive manner.

a::e
e::i
i::o
o::u
u::a


# Vyxal, 9 bytes

k∨:½ƛǓ;∑Ŀ


Try it Online!

Basic transliteration.

## PHP, 90 Bytes

Try it online

Code

function f($s){echo strtr($s,array_combine(str_split(UuAaEeIiOo),str_split(AaEeIiOoUu)));}


Explanation

function f($s){ echo strtr($s,                          #The string to operate
array_combine(               #combining arrays
str_split(UuAaEeIiOo),  #splitting this strings
str_split(AaEeIiOoUu))
# With array combine php creates an array like
# ["U"=>"A", "a"=>"e"....and so on]
# strtr can replace strings in a string, using an array with
# the values to replace and with what replace each value.
);
}


75 Bytes if ran with php -r using $argv <?=strtr($argv,array_combine(str_split(UuAaEeIiOo),str_split(AaEeIiOoUu)));


# J, 33 bytes

rplc'aeiou',&((;"0)1&|.)'AEIOU'"1


Try it online!

# str, 18 bytes

[aeiouaAEIOUA]#D#U


Try it online!

## Explanation

                       implicit: over each character of the input:
[aeiouaAEIOUA]#D#U
[            ]         push this string
#D       set this to the operation domain
#U     set the charcter to the next character in the domain


# PHP, 38 bytes

Quite simple, not very creative, uses strtr to replace the vowels:

<?=strtr($argn,aeiouAEIOU,eiouaEIOUA);  Run with echo '<input>' | php -nF <filename> or Try it online. • Does this not assume that the input is assigned to the predefined variable argn? If so then that's not valid; you'd need to pass the string as an argument and use $argv1] instead. Apr 23 '18 at 16:01
• @Shaggy No, if you run it with the -F flag, then it works with input on the command line. From the PHP docs on options: -F --process-file PHP file to execute for every input line. Added in PHP 5. The Try it online variable defining is just because some people don't have PHP installed locally, and I couldn't get the -F flag working in TIO. Apr 23 '18 at 16:05
• Thanks, @David - that's my "something new" for PHP today :) Apr 23 '18 at 16:06

# q/kdb+, 36 33 bytes

Solution:

{(v,2#x)1+(v:"aeiouaAEIOUA")?x}@'


Examples:

q){(v,2#x)1+(v:"aeiouaAEIOUA")?x}@'"AEIOUaeiou"
"EIOUAeioua
q){(v,2#x)1+(v:"aeiouaAEIOUA")?x}@'"Programming Puzzles And Code Golf"
"Prugremmong Pazzlis End Cudi Gulf"


Explanation:

Figure out index of vowels, add one to push along to the next and index in. Still think this approach can be significantly improved...

{(v,2#x)1+(v:"aeiouaAEIOUA")?x}@' / the solution
{                             }@' / apply lambda to each character of input
?x    / look up x in...
(                )      / do together
"aeiouaAEIOUA"       / lookup list
v:                     / save as v
(     )                          / do together
2#x                           / take 2 copies of x
v,                              / prepend v


Bonus:

My old **36 byte(()) solution which I think is quite cool, but need to golf down the lists to make it competetive:

ssr/[;"uoiea%UOIEA%";"%uoiea%UOIEA"]


# Charcoal, 35 bytes

ＵＴ≔AUOIEAauoieaσＦ¹¹⊞υ➙§σ⊕ι§σι▷SR⟦Ｓυ


Try it online!

Naive method.

### Explanation:

ＵＴ                                         Set trim option to on, so output won't be a rectangle
≔AUOIEAauoieaσ                          Assign "AUIOEAauioea" to s
Ｆ¹¹                      For i (ι) from 0 to 10
⊞υ                   Push to u (initially empty list)
➙                 Rule of:
§σ⊕ι            S[i + 1]
§σι         to S[i]. This is so a->A gets overwriteen by a->e
▷SR⟦Ｓυ  Replace input as string using u (now a list of rules)