This challenge is a tribute to the winner of Best Picture at the Oscars 2017, La La Land Moonlight!

Write a function/program that takes a string containing only letters [A-Za-z], the four symbols that are common in every day sentences .,'? and spaces, and outputs the string in the style of La La Land.

To be more specific, take the letters up to, and including, the first vowel group, and print/output it twice adding a space each time, then print/output the whole string. y is a vowel in this challenge. Punctuation and capitalization should be kept.

You may assume that all strings contain at least one vowel, and that all strings start with a letter.

Test cases:

La La Land

Moo Moo Moonlight

quEueI quEueI quEueIng

This isn't a single word.
Thi Thi This isn't a single word.

It's fun to play golf
I I It's fun to play golf

Ooo Ooo Ooo

I'm okay
I I I'm okay

Hmm, no. There will be at least one vowel, but it can be anywhere.
Hmm, no Hmm, no Hmm, no. There will be at least one vowel, but it can be anywhere.

Why is y a vowel?
Why Why Why is y a vowel?

This is so the shortest code in each language wins. Explanations are encouraged, also in mainstream languages.

  • 1
    \$\begingroup\$ Test case for case insensitivity: MOONLIGHT. And just for fun: Why did the chicken cross the road? \$\endgroup\$ – Titus Mar 1 '17 at 11:05
  • 35
    \$\begingroup\$ Challenge sponsored by: National Stuttering Association \$\endgroup\$ – sergiol Mar 1 '17 at 23:34
  • 6
    \$\begingroup\$ Or Prof. Quirrell \$\endgroup\$ – Brian J Mar 2 '17 at 19:26
  • 1
    \$\begingroup\$ 6th test case bought to you by Louis Prima and the Jungle Book. Joined just to add this (bad) pun. \$\endgroup\$ – Toby Mar 3 '17 at 16:23

40 Answers 40


Python 3, 102 99 bytes

def l(s,v=0):
 for l in range(len(s)):
  if s[l]in"aeiouyAEIOUY":v=1
  elif v:return(s[:l]+" ")*2+s

Running on IDLE, so the Print/output part stands

>>> l("Land")
'La La Land'

Managed to shave off a space or two, and replace .lower() with simply adding uppercase vowels to the check.


C, 150 146 bytes

f(char*s){char*v="aeiouyAEIOUY",*p=strpbrk(s,v);int i=strspn(p,v),f=i+(p-s),d=0,j=2;while(j--)while(d<f)putchar(s[d++]);d=0,putchar(' ');puts(s);}


#include <stdio.h>
#include <string.h>

int main(void)
    char *s = "Land";  // change this

    char *p = strpbrk(s, "aeiouyAEIOUY");
    int count = strspn(p, "aeiouyAEIOUY");

    int idx = count + (p - s);

    int i, j = 2;

    while (j--)
        while (i < idx)

        i = 0;
        putchar(' ');


How it works:

  • strpbrk finds the first vowel and returns a pointer p.
  • strspn finds how many vowels there are in a row in p and returns an integer count.
  • The index idx of the last vowel equals count (# of vowels) + p - s (index of first vowel).
  • Print the first idx characters in s, twice.

APL (Dyalog), 28 bytes

'(?i)^.*?[aeiouy]+'⎕R'& & &' or 29 chars: '^.*?[aeiouy]+'⎕R'& & &'⍠1

Simply a ((?i) or ⍠1) case-insensitive PCRE Replace of

^ the beginning
.*? zero or more characters (lazy)
[aeiouy]+ one or more vowels


& & & the entire match thrice with spaces inbetween

Version without RegEx, 43 bytes

⊢(↑,' ',↑,' ',⊢)⍨1⍳⍨1 0⍷'aeiouy'∊⍨' ',⍨819⌶

819⌶ lowercase

' ',⍨ append a space

'aeiouy'∊⍨ which letters are vowels

1 0⍷ vowels that are followed by a non-vowel

1⍳⍨ index of first one

⊢()⍨ apply the following tacit function with the string as right argument, and the above index as left argument

 that many characters taken from the string

, followed by

 that many characters taken from the string

, followed by

 the string


Japt v2.0a0, 17 bytes


Try it | Check all test cases


                      :Implicit input of string
r/^.*?\y+/            :RegEx replace
                      :  ^ is required to save the extra bytes disabling the g flag
                      :  \y is the class for [AEIOUYaeiouy]
          @[XXX]      :An array containing three copies of the match
                ¸     :Joined to a string with spaces
                      :Implicit output of result

Julia 0.6, 45 bytes

s->(match(r"^.*?[aeiouy]+"i,s).match*" ")^2*s

Try it online!

A pretty straightforward regex-based solution (for now at least). * is a concatenation operator when applied to strings, and ^ is a self-concatenation operator - "Moo "^2 == "Moo "*"Moo " == "Moo Moo ".


Java 8, 49 bytes

Lambda from String to String.

s->s.replaceAll("(?i)^(.*?[aeiouy]+)","$1 $1 $1")

Try It Online

The same regular expression approach many are using. (?i) turns on case insensitivity, the capture group is substituted for each $1 in the replacement string, and .*? is lazy so that it doesn't match vowels.


Jelly, 13 bytes


Try it online!

Full program.


SNOBOL4 (CSNOBOL4), 70 bytes

	T (ARB SPAN('AEIOUYaeiouy')) . X
	OUTPUT =X ' ' X ' ' T

Try it online!


Node.JS, 64 bytes

console.log(process.argv[2].replace(/.*?[aeiouy]+/i,"$& $& $&"))
  • \$\begingroup\$ just use a lambda function, it's shorter \$\endgroup\$ – ASCII-only Apr 4 at 1:07

C# (Visual C# Interactive Compiler), 79 75 bytes

Since it hasn't been posted yet...

f=>{var v=new Regex(".*?[aeiouyAEIOUY]+").Match(f).Value+" ";return v+v+f;}

Try it online!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.