Ot wes thi bist uf tomis

36

5

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 had everything before us, we had nothing before us,
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

AJFaraday

Posted 2018-04-23T14:56:16.310

Reputation: 10 466

Related – Rod – 2018-04-23T18:18:25.283

20

A.k.a. The Great Vowel Shift

– Angs – 2018-04-23T18:27:29.387

@Angs A Tale Of Two Cases? – AJFaraday – 2018-04-23T18:30:05.983

4Hmm. Olde English? – iammax – 2018-04-24T01:26:26.507

Related – streetster – 2018-04-24T06:19:23.147

10Still an easier read than Beowulf. – Smeato – 2018-04-24T10:50:38.700

If you think it's fun to read this stuff, I can recommend a book named Feersum Endjinn by Iain M. Banks. It has entire chapters written like this. – JohnEye – 2018-04-24T15:06:48.423

4Looks like a kiwi-translater to me. – Magoo – 2018-04-24T16:30:48.640

1I like how “evil” when ciphers to “ivol”, is effectively pronounced the same way. – Enrico Borba – 2018-05-03T06:34:02.370

Answers

11

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.

Multi

Posted 2018-04-23T14:56:16.310

Reputation: 425

22

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."

BradC

Posted 2018-04-23T14:56:16.310

Reputation: 6 099

1I'm genuinely shocked that SQL is even close to competitive for this. Also, that's a cool function! Thanks for telling us :) – Fund Monica's Lawsuit – 2018-04-25T14:40:41.473

@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. – BradC – 2018-04-25T15:44:32.570

14

Haskell, 52 bytes

(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.

Post Rock Garf Hunter

Posted 2018-04-23T14:56:16.310

Reputation: 55 382

14

Bash + coreutils, 24

tr aeiouAEIOU eiouaEIOUA

Try it online!

Digital Trauma

Posted 2018-04-23T14:56:16.310

Reputation: 64 644

12

Retina, 10 9 8 bytes

T`uo`vVA

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.

FryAmTheEggman

Posted 2018-04-23T14:56:16.310

Reputation: 16 206

9 bytes: T`_o`uvUV. – Neil – 2018-04-23T15:25:22.170

This is a remarkably short answer! – AJFaraday – 2018-04-23T15:25:34.047

@Neil clever, thanks! I thought putting an _ in the from set would treat it literally, but it looks like it doesn't do that. – FryAmTheEggman – 2018-04-23T15:31:53.220

@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. – FryAmTheEggman – 2018-04-24T05:12:20.933

@FryAmTheEggman I don't think it helps here. The "cyclic" in the name has little to do with the "cyclic" in this challenge (it means that the mapping for each character cycles through various resulting characters as you transliterate the string). Let me know if you do find a shorter solution though. – Martin Ender – 2018-04-24T05:14:33.547

9

Perl 5 + -p, 24 23 bytes

y;AEIOUaeiou;EIOUAeioua

Try it online

-1 byte thanks to @DomHastings

Nahuel Fouilleul

Posted 2018-04-23T14:56:16.310

Reputation: 5 582

1We don't count -p as +1 anymore, instead we consider that this answer is in "Perl 5 + -p". – Erik the Outgolfer – 2018-04-23T15:14:42.423

1This also works in sed – user41805 – 2018-04-23T18:19:05.283

1If you use ; as the delimiter you can save a byte! – Dom Hastings – 2018-04-23T19:08:54.870

updated, @Cowsquack not anymore – Nahuel Fouilleul – 2018-04-24T07:38:34.783

6

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

mypetlion

Posted 2018-04-23T14:56:16.310

Reputation: 702

Where does this perform I/O? – reinierpost – 2018-04-24T14:42:54.557

@reinierpost It's a function. The input is via the x parameter. In python, lambda functions don't need a return statement. – mypetlion – 2018-04-24T16:04:29.517

6

C, 85 76 67 65 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
}

O.O.Balance

Posted 2018-04-23T14:56:16.310

Reputation: 1 499

You can save 7 bytes by using "AEIOUAaeioua" directly, so you can drop int*t=...;, since you only use t once. – Kevin Cruijssen – 2018-04-24T09:41:47.773

@KevinCruijssen Thanks! – O.O.Balance – 2018-04-24T10:06:11.923

f(char*c){for(;*c;)putchar((strchr("AEIOUAaeioua",*c++)?:c-2)[1]);} works for me (gcc 7.3). – Christoph – 2018-04-24T13:19:13.050

@Christoph very nice. I had no idea you could leave out the second operand to ?:. – O.O.Balance – 2018-04-24T13:46:14.983

1Seems to be a none standard extension from gcc. I knew it from php and simply tried it. – Christoph – 2018-04-24T14:14:07.720

Can we output a final "\0"? If yes then f(char*c){putchar((strchr("AEIOUAaeioua",*c++)?:c-2)[1])&&f(c);} works just fine. – Christoph – 2018-04-25T06:54:26.017

1

@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: https://tio.run/##S9ZNzknMS///P00jOSOxSCtZs7qgtATE1NAoLilKzijSUHJ09fQPdUxMzcwvTVTS0UrW1ta0t0rWNdKMNozVVFMD6tS0rv2fm5iZp6GpUM3Fmaah5FmiUJ5YrFCSkaqQlFpcopCfplCSmZtarKOQiZApzy9CllLStOaq/Q8A

– O.O.Balance – 2018-04-25T08:20:13.167

1@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. – Peter Cordes – 2018-04-25T09:14:51.660

2

@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.

– Christoph – 2018-04-25T09:31:48.377

I'm curious as to what does 1[…] do? – None – 2018-08-02T21:15:42.473

1@Rogem Because of the commutative property of addition, a[b]==*(a+b)==*(b+a)==b[a]. Therefore 1[...]==(...)[1] – ceilingcat – 2018-08-02T22:27:56.480

5

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!

Giuseppe

Posted 2018-04-23T14:56:16.310

Reputation: 21 077

5

Jelly, 11 bytes

Øcs5ṙ€-Ẏ,Ʋy

Try it online!

Erik the Outgolfer

Posted 2018-04-23T14:56:16.310

Reputation: 38 134

5

Python 2, 79 68 67 bytes

-1 byte thanks to @ArnoldPalmer

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

Try it online!

Dead Possum

Posted 2018-04-23T14:56:16.310

Reputation: 3 256

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. – Arnold Palmer – 2018-04-24T03:10:06.743

@ArnoldPalmer Thanks! It's ok, I was away and they all missed me :D – Dead Possum – 2018-04-24T09:55:10.147

5

JavaScript (ES6), 60 bytes

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

Try it online!

Arnauld

Posted 2018-04-23T14:56:16.310

Reputation: 111 334

s=>s.replace(/./g,c=>'auoieaAUOIEA'.match(".(?=${c})")||c) – tsh – 2018-04-24T06:34:57.817

Error: only. => unlya – l4m2 – 2018-04-25T01:36:44.793

4

Ruby -p, 31 bytes

$_.tr!"AEIOUaeiou","EIOUAeioua"

Try it online!

Kirill L.

Posted 2018-04-23T14:56:16.310

Reputation: 6 693

4

05AB1E, 14 13 11 bytes

žMDÀ‡žMuDÀ‡

Try it online!

Kaldo

Posted 2018-04-23T14:56:16.310

Reputation: 1 135

1

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.

– Kevin Cruijssen – 2018-08-02T14:12:58.567

@KevinCruijssen Thanks ! Isn't that something that was fixed in a recent 05AB1E release ? – Kaldo – 2018-08-02T14:39:04.407

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.

– Kevin Cruijssen – 2018-08-02T14:41:13.357

4

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.

user48543

Posted 2018-04-23T14:56:16.310

Reputation:

4

Japt 2.0, 25 21 bytes

I had fun golfing this one with Shaggy.

r\v@=`aeia`pu)g1+UbX

Run it here.

Oliver

Posted 2018-04-23T14:56:16.310

Reputation: 7 160

123 bytes – Shaggy – 2018-04-23T17:10:44.297

1@Shaggy That doesn't work with capital vowels. – Oliver – 2018-04-23T17:37:13.377

1

In that case ... 22 bytes.

– Shaggy – 2018-04-23T18:09:43.037

1

@Shaggy This is fun...21 bytes

– Oliver – 2018-04-23T18:21:38.333

1Nice! I think that's the first time I've seen S.p(f) used. – Shaggy – 2018-04-23T18:26:33.820

1@Shaggy Yeah, same. I tried it on a whim, and was surprised that it actually worked :P – Oliver – 2018-04-23T18:27:24.670

4

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

Kevin Cruijssen

Posted 2018-04-23T14:56:16.310

Reputation: 67 575

3

Retina 0.8.2, 20 bytes

T`_o`A\EI\OUAaei\oua

Try it online! Link includes test cases.

Neil

Posted 2018-04-23T14:56:16.310

Reputation: 95 035

3

APL+WIN, 55 bytes

Prompts for input string:

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

Graham

Posted 2018-04-23T14:56:16.310

Reputation: 3 184

3

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")

zmerch

Posted 2018-04-23T14:56:16.310

Reputation: 541

3

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.

James

Posted 2018-04-23T14:56:16.310

Reputation: 54 537

3

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

vazt

Posted 2018-04-23T14:56:16.310

Reputation: 311

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 – Peter Taylor – 2018-04-23T21:07:18.203

3

AutoHotkey, 24 bytes

AuotHotkey automatically replaces letters in a case sensitive manner.

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

nelsontruran

Posted 2018-04-23T14:56:16.310

Reputation: 241

2

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.

Ethan

Posted 2018-04-23T14:56:16.310

Reputation: 435

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. – Shaggy – 2018-04-23T16:01:26.573

2

@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.

– Ethan – 2018-04-23T16:05:09.393

1Thanks, @David - that's my "something new" for PHP today :) – Shaggy – 2018-04-23T16:06:30.157

2

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)));

Francisco Hahn

Posted 2018-04-23T14:56:16.310

Reputation: 591

2

Elm, 127 123 121 112 bytes

import String as S
f a b=case a of
 c::d::e->if c==b then d else f(d::e)b
 _->b
S.map(S.toList"aeiouaAEIOUA"|>f)

Explanation

This Elm answer is a port of my Haskell answer. I am still learning Elm so there might be a good deal of golfing that can be done. There are a couple of differences here between Elm and Haskell. Elm does not allow multiple declarations of a function so we have to use case instead. Elm is also rather fussy about strings. They are not list of characters and thus have to be treated differently then lists. In fact in order to do any useful of manipulations on strings we have to import a library. Aside from that there are a couple of small differences :: is the list cons operator and (|>)=flip($).

You can test the code here, with the following wrapper:

import Html exposing (text)
import String as S
f a b=case a of
 c::d::e->if c==b then d else f(d::e)b
 _->b
g=S.map(S.toList"aeiouaAEIOUA"|>f)
main=g"It was a dark and stormy night"|>text

Post Rock Garf Hunter

Posted 2018-04-23T14:56:16.310

Reputation: 55 382

2

J, 33 bytes

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

Try it online!

Galen Ivanov

Posted 2018-04-23T14:56:16.310

Reputation: 13 815

2

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

Conor O'Brien

Posted 2018-04-23T14:56:16.310

Reputation: 36 228

2

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
        1+                        / add one
 (     )                          / 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"]

streetster

Posted 2018-04-23T14:56:16.310

Reputation: 3 635

2

Charcoal, 35 bytes

UT≔AUOIEAauoieaσF¹¹⊞υ➙§σ⊕ι§σι▷SR⟦Sυ

Try it online!

Naive method.

Explanation:

UT                                         Set trim option to on, so output won't be a rectangle
    ≔AUOIEAauoieaσ                          Assign "AUIOEAauioea" to s
                   F¹¹                      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⟦Sυ  Replace input as string using u (now a list of rules)

ASCII-only

Posted 2018-04-23T14:56:16.310

Reputation: 4 687

2

PHP, 76 bytes.

$s=strtr($s,array_combine(str_split("aeiouAEIOU"),str_split("eiouaEIOUA")));

Check it out!

This was the shortest I was able to do this in PHP.

$s = //overwrite $s variable ($s should be a defined string or input)
    strtr(  //strtr replaces key => value pairs from arrays in a string
        $s, //the string we are converting
        array_combine( //create an array with key value pairs, key should be original vowel letter and value should be it's replacement
            str_split("aeiouAEIOU") //turn vowels (lower and upper) into an array
            ,str_split("eiouaEIOUA") //turn vowel replacements into an array
        )
    );

Grumpy says Reinstate Monica

Posted 2018-04-23T14:56:16.310

Reputation: 121

1

Python 3: 148 126 121 Bytes

Fixed code, saved 22 bytes by not using a flag for case management

Saved 5 bytes by removing uneeded spaces

import re;print(re.sub('a|A',r"e",re.sub('e|E',r"i",re.sub('i|I',r"o",re.sub('o|O',r"u",re.sub('u|U',r"a",input()))))))

Definitely can be improved if i can figure out how to group patters with their respective groups of replaces. Will probaly save 90+ bytes

Mercury Platinum

Posted 2018-04-23T14:56:16.310

Reputation: 161

1

Tcl, 56 bytes

proc C s {string map [split aeeiioouuaAEEIIOOUUA ""] $s}

Try it online!

sergiol

Posted 2018-04-23T14:56:16.310

Reputation: 3 055

1

APL (Dyalog Classic), 54 50 bytes

{(X,⍨1⌽v)[X⍳⍨v,X←(⍵,⍨1⌽w)[⍵⍳⍨⍵,⍨w←819⌶v←'AEIOU']]}

Try it online!

Zacharý

Posted 2018-04-23T14:56:16.310

Reputation: 5 710

Very good test case generation! – AJFaraday – 2018-04-24T21:23:42.623

I should've done "aeiouAEIOUbcd!?" or something, but thanks! – Zacharý – 2018-04-24T21:26:13.617

It’s a much more satisfying sentence, tho. – AJFaraday – 2018-04-24T21:27:33.913

Or at least have added a small a. – Zacharý – 2018-04-24T21:36:44.287

Well, “worlda” sounds odd, but “wurlde” sounds very olde English. – AJFaraday – 2018-04-24T22:46:11.490

1

sed, 24 bytes

y/aeiouAEIOU/eiouaEIOUA/

someonewithpc

Posted 2018-04-23T14:56:16.310

Reputation: 191

1

GolfScript, 34 bytes

{.'aeiouAEIOU'?"eiouaEIOUA0"=\or}%

Where 0 denotes a null byte. In the TIO link, I had to use \0, so it is one byte longer.

Try it online!

Simple transliteration. I tried to build the two strings but it was 15 bytes longer.

wastl

Posted 2018-04-23T14:56:16.310

Reputation: 3 089

1

MATL, 15 bytes

,@11+Y2t1_YSXE]

Try it on MATL Online

sundar - Reinstate Monica

Posted 2018-04-23T14:56:16.310

Reputation: 5 296