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, 2017 at 11:05
  • 39
    \$\begingroup\$ Challenge sponsored by: National Stuttering Association \$\endgroup\$
    – sergiol
    Mar 1, 2017 at 23:34
  • 7
    \$\begingroup\$ Or Prof. Quirrell \$\endgroup\$
    – Brian J
    Mar 2, 2017 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, 2017 at 16:23

42 Answers 42


Pyth - 24 bytes


Test Suite.

  • 1
    \$\begingroup\$ I think you maybe forgot y? \$\endgroup\$ Feb 27, 2017 at 18:04

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.

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

Jelly, 13 bytes


Try it online!

Full program.


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.


Vyxal r, 16 bytes


Try it online!


   )              # Lambda from the beginning of the line
k∩                #   Does "aeiouyAEIOUY"
  c               #   Contain the lambdas argument
    M             # Map that lambda over the input string returning a list of 1s and 0s (1 if a vowel and 0 if not)
     ¯            # Differences between each 
      u           # Negative 1
       ḟ          # In the list of the differences, find the first index of that 
                  # (this will be the length of the string to prepend twice (let's call that s), minus 1. Let's call that number l)
        ₌         # Apply the next two elements to the top of the stack
         i        #   Index; get the lth character from the input (0-indexed)
          Ẏ       #   Get the first l characters from the input
           +      # Add (r flag flips argument order). 
                  # Now we have s, but found in a way that if l is -1 (i.e. -1 isn't in the deltas) s isn't just an empty string
            :     # Duplicate
             "    # Pair (resulting in [s, s])
              J   # Prepend (not append because of r flag) that to the input
               Ṅ  # Join by spaces

Thunno 2 J, 16 bytes


Try it online!


ð+k.s€ƇJTȮ⁺ɱð+ḌƤ  # Implicit input
ð+                # Append a space to the input string
  k.s€Ƈ           # Check if each character is in the string "AEIOUYaeiouy"
       JTȮ⁺       # Find the first one-based index of [1, 0]
           ɱ      # Take this many characters from the start of the input
            ð+    # Append a space to this string
              ḌƤ  # Double it and append the input string
                  # Implicit output

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, 2019 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 and acknowledge you have read our privacy policy.

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