Sheffle tho vawols ureund!

42

7

Given an input string, output that string with all vowels a, e, i, o and u swapped at random between each other.

For example, in the string this is a test, there are 4 vowels: [i, i, a, e]. A valid shuffling of those vowels could be [a, i, e, i] therefore yielding the output thas is e tist.

About shuffling

All shuffles shall be equally likely if we consider equal vowels to be distinct. For the example above, those 24 shuffles are possible:

[i1, i2, a, e]    [i1, i2, e, a]    [i1, a, i2, e]    [i1, a, e, i2]
[i1, e, i2, a]    [i1, e, a, i2]    [i2, i1, a, e]    [i2, i1, e, a]
[i2, a, i1, e]    [i2, a, e, i1]    [i2, e, i1, a]    [i2, e, a, i1]
[a, i1, i2, e]    [a, i1, e, i2]    [a, i2, i1, e]    [a, i2, e, i1]
[a, e, i1, i2]    [a, e, i2, i1]    [e, i1, i2, a]    [e, i1, a, i2]
[e, i2, i1, a]    [e, i2, a, i1]    [e, a, i1, i2]    [e, a, i2, i1]

Each one should be equally as likely.

You may not try random shuffles of the entire string until finding one where all vowels are in the right place. In short, your code's running time shall be constant if the input is constant.

Inputs and outputs

  • You may assume that all letters in the input will be lowercase or uppercase. You may also support mixed casing, though this won't give you any bonus.

  • The input will always consist of printable ASCII characters. All characters that are in the input shall be in the output, only the vowels must be shuffled around and nothing else.

  • The input can be empty. There is no guarantee that the input will contain at least one vowel or at least one non-vowel.

  • You may take the input from STDIN, as a function parameter, or anything similar.

  • You may print the output to STDOUT, return it from a function, or anything similar.

Test cases

The first line is the given input. The second line is one of the possible outputs.

<empty string>
<empty string>

a
a

cwm
cwm

the quick brown fox jumps over the lazy dog.
tho qeuck brewn fax jumps ovir the lozy dog.

abcdefghijklmnopqrstuvwxyz
abcdefghujklmnipqrstovwxyz

programming puzzles & code golf
pregromming pezzlos & coda gulf

fatalize
fitaleza

martin ender
mirten ander

Scoring

This is , sa tho shirtist enswer en bytes wons.

Fatalize

Posted 2016-08-31T06:41:08.967

Reputation: 32 976

17You English/American people and your lack of y as vowel.. ;) – Kevin Cruijssen – 2016-08-31T07:21:00.223

6@KevinCruijssen I'm not a native speaker and I would also consider y to be a vowel, but last challenge where I said y was a vowel I got asked why I chose that! – Fatalize – 2016-08-31T07:22:20.173

7@KevinCruijssen, letters aren't vowels: sounds are. – Peter Taylor – 2016-08-31T08:45:36.630

@PeterTaylor You're right, came to the same conclusion short after I made my comment. But still, y is a vowel in Baby (although not in Your). If we look at individual letters I personally consider y a vowel, although I can understand why some don't with all the words starting with y in the English language. – Kevin Cruijssen – 2016-08-31T08:59:51.373

6+1 for cwm. Keeping mountaineering and/or Welsh alive ;) – Beta Decay – 2016-08-31T09:19:58.963

2@KevinCruijssen Don't have a cow about vowels that aren't commonly considered so. – corsiKa – 2016-08-31T19:21:29.887

Answers

13

Jelly, 15 bytes

f€“¡ẎṢɱ»ðœpżFẊ¥

Try it online!

How it works

f€“¡ẎṢɱ»ðœpżFẊ¥  Main link. Argument: s (string)

  “¡ẎṢɱ»         Yield "aeuoi"; concatenate "a" with the dictionary word "euoi".
f€               Filter each character in s by presence in "aeuoi".
                 This yields A, an array of singleton and empty strings.
        ð        Begin a new, dyadic chain. Left argument: A. Right argument: s
         œp      Partition s at truthy values (singleton strings of vowels) in A.
            FẊ¥  Flatten and shuffle A. This yields a permutation of the vowels.
           ż     Zip the partition of consonants with the shuffled vowels.

Dennis

Posted 2016-08-31T06:41:08.967

Reputation: 196 637

Why does this seem fairly slow compared to other answers? – Fatalize – 2016-08-31T07:20:57.257

Jelly imports SymPy and NumPy before anything else. This program and the empty program have roughly the same execution time. – Dennis – 2016-08-31T07:23:41.873

15

Before anyone asks, euoi is a cry of impassioned rapture in ancient Bacchic revels.

– Dennis – 2016-08-31T07:26:38.627

5@Dennis Out of curiosity though, why does Jelly have built in dictionary words? Where does it get these dictionary words from? – Kevin Cruijssen – 2016-08-31T07:31:16.077

1

@KevinCruijssen When I designed Jelly, there already were a few golfing languages that used shoco, and simply using an English dictionary seemed like a good way to improve on that idea. I used the file /usr/share/dict/words from my computer and included it in the Jelly interpreter.

– Dennis – 2016-08-31T21:19:19.993

As the FX¥ appears to be executed monadically, why does it fail when replacing the ¥ with a $? – caird coinheringaahing – 2018-03-24T23:46:49.363

@cairdcoinheringaahing Because ż forks if the link to its right is a monad. – Dennis – 2018-03-25T00:01:39.477

17

R, 92 91

Can't comment yet so I'm adding my own answer albeit very similar to @Andreï Kostyrka answer (believe it or not but came up with it independently).

s=strsplit(readline(),"")[[1]];v=s%in%c("a","e","i","o","u");s[v]=sample(s[v]);cat(s,sep="")

Ungolfed

s=strsplit(readline(),"")[[1]]    # Read input and store as a vector
v=s%in%c("a","e","i","o","u")     # Return TRUE/FALSE vector if vowel
s[v]=sample(s[v])                 # Replace vector if TRUE with a random permutation of vowels
cat(s,sep="")                     # Print concatenated vector

Saved one byte thanks to @Vlo

s=strsplit(readline(),"")[[1]];s[v]=sample(s[v<-s%in%c("a","e","i","o","u")]);cat(s,sep="")

Billywob

Posted 2016-08-31T06:41:08.967

Reputation: 3 363

5Honestly, I cannot believe. Just kidding. Nice trick to save some bytes! – Andreï Kostyrka – 2016-08-31T08:49:12.707

Just to be honest, I am not stealing your ideas to golf my answer further. – Andreï Kostyrka – 2016-08-31T08:50:05.287

3Hehe, gotta get them sweet upvotes so I can comment ;) – Billywob – 2016-08-31T08:53:09.350

Save a byte with in-line assignment 91 bytes s=strsplit(readline(),"")[[1]];s[v]=sample(s[v<-s%in%c("a","e","i","o","u")]);cat(s,sep="") – Vlo – 2016-09-01T20:17:15.870

Save another byte by using el() instead of [[1]]. – Andreï Kostyrka – 2018-03-23T13:11:47.650

11

R, 99 98 89 bytes

x=el(strsplit(readline(),""))
z=grepl("[aeiou]",x)
x[z]=x[sample(which(z))]
cat(x,sep="")

Seems to be the first human-readable solution! Thanks to Giuseppe for saving 9 bytes!

Test cases:

tho qaeck bruwn fux jemps over tho lozy dig.
progremmang pozzlos & cide gulf

Seems that there is no way to make an internal variable assignment (inside, like, cat), and again some people are going to prove I am wrong...

Andreï Kostyrka

Posted 2016-08-31T06:41:08.967

Reputation: 1 389

2letters[c(1,5,9,15,21)] is 1 byte longer, and OEIS A161536 and A215721 seem to be of little to no help either. – Andreï Kostyrka – 2016-08-31T08:08:24.043

Wouldn't z=grepl("[aeiou]",x) be shorter? – Giuseppe – 2018-03-24T21:54:51.513

@Giuseppe You did it again! Thanks. – Andreï Kostyrka – 2018-03-24T22:00:53.290

10

CJam, 23 bytes

lee_{"aeiou"&},_mrerWf=

Try it online!

Explanation

l            e# Read input, e.g. "foobar".
ee           e# Enumerate, e.g. [[0 'f] [1 'o] [2 'o] [3 'b] [4 'a] [5 'r]].
_            e# Duplicate.
{"aeiou"&},  e# Keep those which have a non-empty intersection with this string
             e# of vowels, i.e. those where the enumerated character is a vowel.
             e# E.g. [[1 'o] [2 'o] [4 'a]].
_            e# Duplicate.
mr           e# Shuffle the copy. E.g. [[2 'o] [4 'a] [1 'o]].
er           e# Transliteration. Replaces elements from the sorted copy with
             e# the corresponding element in the shuffled copy in the original list.
             e# [[0 'f] [2 'o] [4 'a] [3 'b] [1 'o] [5 'r]].
Wf=          e# Get the last element of each pair, e.g. "foabor".

Martin Ender

Posted 2016-08-31T06:41:08.967

Reputation: 184 808

5

05AB1E, 17 bytes

žMÃ.r`¹vžMyå_iy}?

Explanation

žMÃ                # get all vowels from input
   .r`             # randomize them and place on stack
      ¹v           # for each in input
        žMyå_i }   # if it is not a vowel
              y    # push it on stack
                ?  # print top of stack

Try it online!

Emigna

Posted 2016-08-31T06:41:08.967

Reputation: 50 798

5

Python 3, 109 bytes

Only supports lowercase vowels.

Thanks to @Alissa for saving an extra byte.

import re,random
def f(s):r='[aeiou]';a=re.findall(r,s);random.shuffle(a);return re.sub(r,lambda m:a.pop(),s)

Ideone it!

Beta Decay

Posted 2016-08-31T06:41:08.967

Reputation: 21 478

wouldn't it be shorter if it's a function taking string and returning that string with shuffled vowels? – Alissa – 2016-08-31T12:57:46.803

@Alissa Thanks, it saved one byte! :D – Beta Decay – 2016-08-31T13:28:15.410

not sure if it will be any shorter, but you could a.pop(random.randrange(0,len(a))) instead of shuffling a – Alissa – 2016-08-31T15:26:48.320

4

TSQL, 275 bytes

Golfed:

DECLARE @ VARCHAR(99)='the quick brown fox jumps over the lazy dog.'

;WITH c as(SELECT LEFT(@,0)x,0i UNION ALL SELECT LEFT(substring(@,i+1,1),1),i+1FROM c
WHERE i<LEN(@)),d as(SELECT *,rank()over(order by newid())a,row_number()over(order by 1/0)b
FROM c WHERE x IN('a','e','i','o','u'))SELECT @=STUFF(@,d.i,1,e.x)FROM d,d e
WHERE d.a=e.b PRINT @

Ungolfed:

DECLARE @ VARCHAR(max)='the quick brown fox jumps over the lazy dog.'

;WITH c as
(
  SELECT LEFT(@,0)x,0i
  UNION ALL
  SELECT LEFT(substring(@,i+1,1),1),i+1
  FROM c
  WHERE i<LEN(@)
),d as
(
  SELECT 
    *,
    rank()over(order by newid())a,
    row_number()over(order by 1/0)b
  FROM c
  WHERE x IN('a','e','i','o','u')
)
SELECT @=STUFF(@,d.i,1,e.x)FROM d,d e
WHERE d.a=e.b
-- next row will be necessary in order to handle texts longer than 99 bytes
-- not included in the golfed version, also using varchar(max) instead of varchar(99)
OPTION(MAXRECURSION 0) 

PRINT @

Fiddle

t-clausen.dk

Posted 2016-08-31T06:41:08.967

Reputation: 2 874

3

Japt v2.0a0, 14 13 bytes

ō²f\v
NÌr\v@o

Try it


Explanation

           :Implicit input of string U.
ö²         :Generate a random permutation of U.
  f\v      :Get all the vowels as an array.
\n         :Assign that array to U.
NÌ         :Get the last element in the array of inputs (i.e., the original value of U)
  r\v      :Replace each vowel.
     @o    :Pop the last element from the array assigned to U above.

Shaggy

Posted 2016-08-31T06:41:08.967

Reputation: 24 623

3

Java 7, 243 241 bytes

import java.util.*;String c(char[]z){List l=new ArrayList();char i,c;for(i=0;i<z.length;i++)if("aeiou".indexOf(c=z[i])>=0){l.add(c);z[i]=0;}Collections.shuffle(l);String r="";for(i=0;i<z.length;i++)r+=z[i]<1?(char)l.remove(0):z[i];return r;}

Yes, this can probably be golfed quite a bit, but Java doesn't have any handy built-ins for this a.f.a.i.k... Also, I kinda forgot the codegolfed array-variant for Collections.shuffle..

Ungolfed & test cases:

Try it here.

import java.util.*;
class M{
  static String c(char[] z){
    List l = new ArrayList();
    char i,
         c;
    for(i = 0; i < z.length; i++){
      if("aeiou".indexOf(c = z[i]) >= 0){
        l.add(c);
        z[i] = 0;
      }
    }
    Collections.shuffle(l);
    String r = "";
    for(i = 0; i < z.length; i++){
      r += z[i] < 1
               ? (char)l.remove(0)
               : z[i];
    }
    return r;
  }

  public static void main(String[] a){
    System.out.println(c("".toCharArray()));
    System.out.println(c("a".toCharArray()));
    System.out.println(c("cwm".toCharArray()));
    System.out.println(c("the quick brown fox jumps over the lazy dog.".toCharArray()));
    System.out.println(c("abcdefghijklmnopqrstuvwxyz".toCharArray()));
    System.out.println(c("programming puzzles & code golf".toCharArray()));
    System.out.println(c("fatalize".toCharArray()));
    System.out.println(c("martin ender".toCharArray()));
  }
}

Possible output:

a
cwm
tha queck brown fox jumps evor tho lezy dig.
ebcdifghujklmnopqrstavwxyz
prigrommeng puzzlos & cade golf
fatelazi
mertan inder

Kevin Cruijssen

Posted 2016-08-31T06:41:08.967

Reputation: 67 575

1How about reusing i in the second loop? – Frozn – 2016-08-31T11:06:51.907

I thought "why didn't he go with char[] instead of a List", so I started, but the lack of Arrays.shuffle stopped me right there... – Olivier Grégoire – 2016-08-31T14:24:46.163

Shaved 6 characters with some minor tweaks: import java.util.*;String c(char[]z){List l=new ArrayList();int i=0,j=z.length;for(;i<j;i++)if("aeiou".indexOf(z[i])>=0){l.add(z[i]);z[i]=0;}Collections.shuffle(l);String r="";for(i=0;i<j;i++)r+=z[i]<1?(char)l.remove(0):z[i];return r;} – durron597 – 2016-09-01T19:52:43.990

3

MATL, 15 bytes

tt11Y2m)tnZr7M(

Try it online!

Explanation

tt      % Take input string implicitly. Duplicate twice
11Y2    % Predefined string: 'aeiou'
m       % Logical index that contains true for chars of the input that are vowels
)       % Get those chars from the input string. Gives a substring formed by the
        % vowels in their input order
tnZr    % Random permutation of that substring. This is done via random sampling
        % of that many elements without replacement
7M      % Push logical index of vowel positions again
(       % Assign the shuffled vowels into the input string. Display implicitly

Luis Mendo

Posted 2016-08-31T06:41:08.967

Reputation: 87 464

3

Javascript (ES6), 78 76 bytes

s=>s.replace(r=/[aeiou]/g,_=>l.pop(),l=s.match(r).sort(_=>Math.random()-.5))

Saved 2 bytes thanks to apsillers

Alternate version proposed by apsillers (76 bytes as well)

s=>s.replace(r=/[aeiou]/g,[].pop.bind(s.match(r).sort(_=>Math.random()-.5)))

Test

let f =
s=>s.replace(r=/[aeiou]/g,_=>l.pop(),l=s.match(r).sort(_=>Math.random()-.5))

console.log(f("the quick brown fox jumps over the lazy dog."))

Arnauld

Posted 2016-08-31T06:41:08.967

Reputation: 111 334

1Not an improvement (exact same score), but a fun uglification I found: drop the l=... entirely and use the bound function [].pop.bind(s.match(r).sort(_=>Math.random()-.5))) as the second argument to replace (instead of an arrow function). Maybe there's an improvement to be found down that road, but I haven't found one yet. If you used a JS-superset language that has the bind operator ::, I think you could do (s.match(r).sort(_=>Math.random()-.5)))::pop. – apsillers – 2016-08-31T17:41:16.310

3

Perl, 38 bytes

Includes +1 for -p

Run with the sentence on STDIN

vawols.pl <<< "programming puzzles & code golf"

vawols.pl:

#!/usr/bin/perl -p
@Q=/[aeiou]/g;s//splice@Q,rand@Q,1/eg

Ton Hospel

Posted 2016-08-31T06:41:08.967

Reputation: 14 114

3

Perl 6, 65 bytes

{my \v=m:g/<[aeiou]>/;my @a=.comb;@a[v».from]=v.pick(*);@a.join}

Anonymous function. Assumes lower-case input.

(try it online)

smls

Posted 2016-08-31T06:41:08.967

Reputation: 4 352

3

Ruby 45 + 1 = 46 bytes

+1 byte for -p flag

a=$_.scan(e=/[aeiou]/).shuffle
gsub(e){a.pop}

Jordan

Posted 2016-08-31T06:41:08.967

Reputation: 5 001

3

Brachylog, 39 bytes

@eI:1aToS,I:2f@~:LcS,Tc
.'~e@V;
e.~e@V,

Try it online!

Explanation

  • Main predicate:

    @eI        I is the list of chars of the input.
    :1aT       T is I where all vowels are replaced with free variables.
    oS,        S is T sorted (all free variables come first).
    I:2f       Find all vowels in I.
    @~         Shuffle them.
    :LcS,      This shuffle concatenated with L (whatever it may be) results in S.
                 This will unify the free variables in S with the shuffled vowels.
    Tc         Output is the concatenation of elements of T.
    
  • Predicate 1:

    .          Input = Output…
    '~e@V      …provided that it is not a vowel.
    ;          Otherwise Output is a free variable.
    
  • Predicate 2:

    e.         Output is an element of the input…
    ~e@V,      … and it is a vowel.
    

Fatalize

Posted 2016-08-31T06:41:08.967

Reputation: 32 976

2

PHP, 144 129 bytes

Using lowercase input

$r=Aaeiou;$v=str_shuffle(preg_replace("#[^$r]+#",'',$a=$argv[1]));for(;$i<strlen($a);)echo strpos($r,$a[$i++])?$v[$j++]:$a[$i-1];

Explanation:

$r="aeiou"; // set vowels

preg_replace("#[^$r]+#",'',$argv[1]) // find all vowels in input

$v=str_shuffle() // shuffle them

for(;$i<strlen($a);) // run through the text

strpos($r,$a[$i++])?$v[$j++]:$a[$i-1]; // if it's a vowel print the j-th shuffled vowel else print original text

Crypto

Posted 2016-08-31T06:41:08.967

Reputation: 862

2

PowerShell v3+, 155 99 bytes

param([char[]]$n)$a=$n|?{$_-match'[aeiou]'}|sort{random};-join($n|%{if($_-in$a){$a[$i++]}else{$_}})

Big props to @Ben Owen for the 56-byte golf

Takes input $n, expecting all lowercase, immediately casts it as a char-array.

We pipe that into a Where-Object clause to pull out those elements that -match a vowel, pipe them to Sort-Object with {Get-Random} as the sorting mechanism. Calling Get-Random without qualifiers will return an integer between 0 and [int32]::MaxValue -- i.e., assigning random weights to each element on the fly. We store the randomized vowels into $a.

Finally, we loop through $n. For each element, |%{...}, if the current character is somewhere -in $a, we output the next element in $a, post-incrementing $i for the next time. Otherwise, we output the current character. That's all encapsulated in parens and -joined together into a string. That string is left on the pipeline, and output is implicit at program conclusion.

Test cases

PS C:\Tools\Scripts\golfing> 'a','cwm','the quick brown fox jumps over the lazy dog.','abcdefghijklmnopqrstuvwxyz','programming puzzles & code golf','fatalize','martin ender'|%{.\vawols.ps1 $_}
a
cwm
thu qaeck brown fix jomps ovor thu lezy deg.
abcdofghejklmnupqrstivwxyz
prugrammong pizzles & code golf
fitaleza
mertin endar

AdmBorkBork

Posted 2016-08-31T06:41:08.967

Reputation: 41 581

You can save a lot of bytes here by iterating through $n's characters and matching on each vowel to output the char-array of vowels instead. Something like: $a=[char[]]$n|?{$_-match'[aeiou]'}|sort{random} – Ben Owen – 2016-09-01T19:41:24.773

@BenOwen Holy dang, yes. Thanks for the 56-byte golf. For the life of me, I could just not figure out a better way to construct $a. – AdmBorkBork – 2016-09-01T19:54:25.477

2

Pyth, 26 bytes

J"[aeiou]"s.i:QJ3.Sf}TPtJQ

A program that takes input of a quoted string and prints the shuffled string.

Try it online

How it works

J"[aeiou]"s.i:QJ3.Sf}TPtJQ  Program. Input: Q
J"[aeiou]"                  J="[aeiou]"
             :QJ3           Split Q on matches of regex J, removing vowels
                      PtJ   J[1:-1], yielding "aeiou"
                   f}T   Q  Filter Q on presence in above, yielding vowels
                 .S         Randomly shuffle vowels
           .i               Interleave non-vowel and vowel parts
          s                 Concatenate and implicitly print

TheBikingViking

Posted 2016-08-31T06:41:08.967

Reputation: 3 674

2

Actually, 24 bytes

;"aeiou";╗@s@`╜íu`░╚@♀+Σ

Try it online!

Explanation:

;"aeiou";╗@s@`╜íu`░╚@♀+Σ
;                         dupe input
 "aeiou";╗                push vowels, store a copy in reg0
          @s              split one copy of input on vowels
            @`╜íu`░       take characters from other copy of input where
              ╜íu           the character is a vowel (1-based index of character in vowel string is non-zero)
                   ╚      shuffle the vowels
                    @♀+   interleave and concatenate pairs of strings
                       Σ  concatenate the strings

Mego

Posted 2016-08-31T06:41:08.967

Reputation: 32 998

2

Bash, 75 bytes

paste -d '' <(tr aeoiu \\n<<<$1) <(grep -o \[aeiou]<<<$1|shuf)|paste -sd ''

Takes the string as an argument and prints the result to stdout.

Eg

for x in "" "a" "cwm" \
         "the quick brown fox jumps over the lazy dog." \
         "abcdefghijklmnopqrstuvwxyz" \
         "programming puzzles & code golf" \
         "fatalize" "martin ender"; do
  echo "$x";. sheffle.sh "$x"; echo
done

prints

<blank line>
<blank line>

a
a

cwm
cwm

the quick brown fox jumps over the lazy dog.
tho quuck brown fix jamps ever the lozy dog.

abcdefghijklmnopqrstuvwxyz
ibcdefghajklmnopqrstuvwxyz

programming puzzles & code golf
progremmong pazzlus & cedo gilf

fatalize
fetilaza

martin ender
mertan endir

rici

Posted 2016-08-31T06:41:08.967

Reputation: 601

2

Bash, 89

Assumes all input to be lowercase.

a=`tee z|grep -o [aeiou]`
[ -n "$a" ]&&tr `tr -d \ <<<$a` `shuf -e $a|tr -d '
'`<z||cat z

user16402

Posted 2016-08-31T06:41:08.967

Reputation:

2

Python 3, 106 bytes

Lowercase only.

import re,random
def f(s):s=re.split('([aeiou])',s);v=s[1::2];random.shuffle(v);s[1::2]=v;return''.join(s)

Ken 'Joey' Mosher

Posted 2016-08-31T06:41:08.967

Reputation: 136

1

K (oK), 29 bytes

Solution:

{x[a:&x in"aeiou"]:x@(-#a)?a}

Try it online!

Examples:

"pregrommeng pizzlas & codo gulf"
{x[a:&x in"aeiou"]:x@(-#a)?a}"programming puzzles & code golf"
"pregremmong puzzlos & coda gilf"
{x[a:&x in"aeiou"]:x@(-#a)?a}"programming puzzles & code golf"
"pregrommeng pazzlos & cidu golf"

Explanation:

Find locations of the vowels and replace with the vowels drawn in a random order.

{x[a:&x in"aeiou"]:x@(-#a)?a} / the solution
{                           } / anonymous function with input x
 x[              ]            / index into x at these indices
      x in"aeiou"             / is character a vowel
     &                        / indices where true
   a:                         / assign to add
                  :           / assign
                          ?a  / draw randomly from a
                     (   )    / do this together
                       #a     / count length of a
                      -       / negate (draws from list, no duplication)
                   x@         / apply these indices to input

streetster

Posted 2016-08-31T06:41:08.967

Reputation: 3 635

1

PHP >= 5.3, 139 136 bytes (and no errors thrown)

array_map(function($a,$b){echo$a.$b;},preg_split("/[aeiou]/",$s=$argv[1]),str_split(str_shuffle(implode(preg_split("/[^aeiou]/",$s)))));

MonkeyZeus

Posted 2016-08-31T06:41:08.967

Reputation: 461

0

APL (Dyalog Unicode), 21 bytes

{⍵[?⍨≢⍵]}@{⍵∊'AEIOU'}

Try it online!

Assumes uppercase.

Erik the Outgolfer

Posted 2016-08-31T06:41:08.967

Reputation: 38 134

Would {⍵∊'AEIOU'} → ∊∘'AEIOU' work? – user41805 – 2018-04-29T14:55:25.277

@Cowsquack I don't think so, since then it would be parsed as ({⍵[?⍨≢⍵]}@∊)∘'AEIOU'. – Erik the Outgolfer – 2018-04-29T15:01:09.987

0

Kotlin, 122 118 bytes

x->val v=x.filter{"aeiuo".contains(it)}.toList().shuffled()
x.split(Regex("[aeiou]")).reduceIndexed{i,a,s->a+v[i-1]+s}

Try it online!

Makotosan

Posted 2016-08-31T06:41:08.967

Reputation: 503