12
\$\begingroup\$

Definition of long text

Long text usually shows emphasis, for instance, loooooool or yaaaaaaaaaay. Usually the vowel is replicated many times. In this challenge we require:

  • At least 3 times, which means yaaay and yaaaay are allowed, but yay and yaay are not.

  • Consistent, which means that shoes can turn out be shoooeees or shooooeeees but not shoooeeees or shooooeees. Of course, it seems that no one would do that, however, this is to reinforce the next law.

  • Undoubling, which means beeping turns out to be beeepiiing or beeeepiiiing but not beeeeeepiiing or beeeeeeeepiiiing. This is not the case for long text, but such makes this challenge non-trivial.

  • Thus, the long text might turn out shorter than the original text, that is, aaaaa can turn out to be aaa.

Your challenge

Input

Your input will be a sentence, that is, you may not assume there are only words. We do not guarantee all will be English words, so look out for theeeeeeeeese.

Output

The long text for the input.

Test cases

We assume you repeat 3 times.

The fox yawns... => Theee fooox yaaawns...

Everything is good!!!!! => Eeeveeerythiiing iiis goood!!!!! and NOT EEEveeerythiiing iiis gooooood!!!!!

Eeny, meeny, miny, moe => Eeeeeeny, meeeny, miiiny, moooeee

AAARGH => AaaRGH

Weeeeeeeeheeeeeee => Weeeheee

Note the treatment of capital letters: The first letter remains capital, and the others are lowered. eE will be eeeEee, they won't be the same. "Undoubling" only happens for letters which are of the same case (like ee or AA, but not for Ee)

Only the letters from a, e, i, o, and u are vowels, case insensitive.

\$\endgroup\$
5
  • 5
    \$\begingroup\$ "laugh out out out out out out out out out out loud" is an interesting way of expressing amusement ;-). \$\endgroup\$ May 19 at 16:59
  • \$\begingroup\$ Maybe I'm overlooking something, but shouldn't yay as input result in yyyaaayyy? \$\endgroup\$ May 20 at 13:22
  • 1
    \$\begingroup\$ Only the letters from a, e, i, o, and u are vowels, case insensitive. @LarsKristensen \$\endgroup\$ May 20 at 14:46
  • \$\begingroup\$ For test case 3, should "Eeeeeeny" be "Eeeny"? Or are the capitals treated separately? \$\endgroup\$
    – Luigi
    May 20 at 16:53
  • 1
    \$\begingroup\$ Shouldn't we be looking out for theeeeeseeeee? \$\endgroup\$
    – COTO
    May 20 at 21:10

15 Answers 15

15
\$\begingroup\$

Vyxal d, 10 bytes

ĠƛhA[h:d⇩+

Try it Online!

Explained

ĠƛhA[h:d⇩+
Ġƛ         # to each group of consecutive characters: 
  hA       #   is the character a vowel?
    [      #   if so:
     h:d   #     Push the character and a string with two copies of that character
        ⇩+ #     and add the lowercase version of that to the character. 
# The -d flag flattens all sublists to depth 1 and then sums the list.
\$\endgroup\$
4
  • \$\begingroup\$ YOu are only supposed to capitalize the vowel if it is capitalized i.e. This -> Thiiis \$\endgroup\$ May 19 at 3:37
  • \$\begingroup\$ OK this is now good. \$\endgroup\$ May 19 at 3:39
  • \$\begingroup\$ hDA and then no h: I think (on mobile) \$\endgroup\$
    – emanresu A
    May 19 at 3:42
  • \$\begingroup\$ @emanresuA that doesn't account for duplicate consonants \$\endgroup\$
    – lyxal
    May 19 at 3:43
10
\$\begingroup\$

Perl 5 -p, 29 bytes

Now handles undoubling thanks to [@Jo King]!

s/((?i)[aeiou])\1*/$1\L$1$1/g

Try it online!

\$\endgroup\$
0
7
\$\begingroup\$

Jelly, 15 bytes

ŒgµŒlṁ3fØcȯaẆḢ)

Try it online!

Œgµ           )    For each run of consecutive equal elements:
   Œl              Lowercase it,
     ṁ3            mold it to length 3,
       fØc         remove non-vowels,
          ȯ        and substitute the original run if that left it empty.
           aẆḢ     Fix the capitalization:
           a       vectorizing logical AND with
            Ẇ      each sublist of the run, individually
           a       because of something to do with how vectorization handles depth?
             Ḣ     and take the head of the resulting list.
\$\endgroup\$
6
\$\begingroup\$

Python, 78 bytes

lambda s:re.sub(r"([aeiouAEIOU])\1*",lambda m:m[1]+2*m[1].lower(),s)
import re

Attempt This Online!

I don't read Perl unless under duress, but if would I'd have to note that this looks very similar to @Dom Hastings' answer.

\$\endgroup\$
6
\$\begingroup\$

JavaScript (ES6), 63 bytes

Repeats 3 times.

s=>s.replace(/([AEIOUaeiou])\1*/g,([c])=>c+(c+c).toLowerCase())

Try it online!

\$\endgroup\$
6
\$\begingroup\$

Retina, 28 bytes

((?i)[aeiou])\1*
$1$l$1$l$1

Try it online! Link includes test cases. Explanation: Port of @DomHastings' Perl answer, but Retina's $l operator only operates on the next token, so either as here it has to be repeated for each token to be lowercased or the letters need to be grouped $1$l$($1$1 which here happens to be the same length as the group does not need to be explicitly closed. Unfortunately Retina's repetition operator does not help here as $12*$l$1 parses as ${12}*$($l$1) so the best we can do is ${1}2*$l$1 which is still the same length. Edit: Saved 1 byte thanks to @DomHastings by porting his (?i) golf from his answer.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Ah.. No wonder I couldn't find $l! I was accidentally looking in the Retina 0.8.2 docs for the word 'lower', instead of the latest Retina version.. :/ I'll change my answer to 0.8.2, although I have the feeling it can still be golfed perhaps. \$\endgroup\$ May 19 at 7:33
  • \$\begingroup\$ @KevinCruijssen Your answer? Oh, right, you answered in between me loading the page and answering. I'll take a look at it. \$\endgroup\$
    – Neil
    May 19 at 8:44
  • \$\begingroup\$ I've just remembered about (?i) since the match is in a capturing group, that can save you another byte (I wonder if there's also a builtin flag for these in Retina?): Try it online! \$\endgroup\$ May 24 at 11:26
  • \$\begingroup\$ @DomHastings Nice! I don't know what you mean about a builtin flag though, since it's only the group itself that can be case insensitive, not the backreference. (Also, you accidentally broke one of the links when you edited your answer.) \$\endgroup\$
    – Neil
    May 24 at 14:36
  • \$\begingroup\$ No worries! I guess I wondered if there was (for example) a character in Retina's codepage that compiled to (?i) (and the other flags) but I guess that's not the case. Not sure it's especially useful though, I guess things like $&, $1, \1, T` being single chars would be more useful so they'd probably be a higher priority to exist... Golf isn't the point of Retina though, so I guess it's not priority. It would probably be trivial to add a wrapper language that supports that kind of thing if it was desired but I digress... \$\endgroup\$ May 24 at 15:38
5
\$\begingroup\$

05AB1E (legacy), 16 bytes

γεDlžMÃĀiÙDlDJ]J

Uses the legacy version of 05AB1E, because there is a bug in the new version with Ā (Python-style truthify builtin) on empty strings "", incorrectly giving a truthy result instead of falsey.

Try it online.

Explanation:

γ              # Split the (implicit) input-string into parts of equal adjacent
               # characters
 ε             # Map over each part:
  D            #  Duplicate the current part
   l           #  Lowercase the copy
    žM         #  Push the vowels constant "aeiou"
      Ã        #  Only keep those characters from the lowercase copy
       Āi      #  If it's non-empty (thus a part with vowels):
         Ù     #   Uniquify to a single character
          D    #   Duplicate it
           l   #   Lowercase the copy
            D  #   Duplicate that again
             J #   Join the three characters together
 ]             # Close the if-statement and map
  J            # Join everything back together
               # (after which the result is output implicitly)
\$\endgroup\$
5
\$\begingroup\$

Husk, 23 bytes

ṁ?oS:oR2_←Iȯ€"AEIOU"a←g

Try it online!

ṁ?oS:oR2_←Iȯ€"AEIOU"a←g
                      g # group identical adjacent letters   
ṁ                       # and, for each group, do this and combine the results:
  ?                     # if
                     ←  # the first element
                    a   # in uppercase form                    
           ȯ€"AEIOU"    # is one of "AEIOU"
         ←              # then get the first element,
        _               # lowercase it,
      R2                # duplicate it,
   S:o                  # and add that to itself;
          I             # otherwise leave the group unchanged
\$\endgroup\$
5
\$\begingroup\$

Python, 82 80 79 bytes

lambda s,*e:''.join([c,(c+2*c.lower())*(e!=c)][(e:=c)in"AEIOUaeiou"]for c in s)

Attempt This Online! First time realising that you can use the walrus operator (:=) in list comprehension to store the previous value of the iterable. Just needs to be initialised

-1 byte thanks to @Unrelated String

\$\endgroup\$
4
5
\$\begingroup\$

Japt, 14 bytes

r"(%v)%1*"Ï+²v

Try it (Includes all test cases)

r"(%v)%1*"Ï+²v     :Implicit input of string
r                  :Replace
 "(%v)%1*"         :Regex /([AEIOUaeiou])\1*/g
          Ï        :Pass the first submatch (i.e., the first character in the match) through the following function
           +       :Append
            ²      :The character duplicated
             v     :And lowercased
\$\endgroup\$
3
\$\begingroup\$

Factor + grouping.extras math.unicode sequences.repeating, 119 111 109 102 100 95 bytes

[ [ ] group-by values [ dup "aeiouAEIOU"⊂ [ 3 cycle 1 cut >lower append ] when ] map-concat ]

Attempt This Online!

Unfortunately Factor's regular expressions are very limited by design so they can't be used to help much. This is still maybe quite golfable regardless.

  • [ ] group-by values Break the input into groups of contiguous equal characters.
  • [ ... ] map-concat Map each group to a sequence, all of which get concatenated together in the end.
  • dup "aeiouAEIOU"⊂ Is it a group of vowels?
  • [ 3 cycle 1 cut >lower append ] when Make it length three and 'capitalize' it if so. (i.e. "aaa" -> "aaa", "AAA" -> "Aaa")
\$\endgroup\$
3
\$\begingroup\$

Retina 0.8.2, 63 47 43 bytes

([AEIOUaeiou])\1*
$1$1$1
rT`L`l`\1([AEIOU])

This can definitely be shorter.. It can, see @Neil's Retina answer. My answer uses the older version, which didn't had builtin $l yet (nor $1$1$1 to 3*$1).
I again have the feeling this can be shorter.. And it can: -16 bytes thank to @Neil, and I've been able to golf it slightly more.

Try it online.

Explanation:

Get all consecutive matches of 1 or more of the same vowels, and shorten/extend them to three of these vowels:

([AEIOUaeiou])\1*
$1$1$1

Lowercase every match of two adjacent uppercase vowels by transliterating in reverse order:

rT`L`l`\1([AEIOU])
\$\endgroup\$
7
  • 1
    \$\begingroup\$ Your last step doesn't work for the test case of AAARGH (it lowercases the R) but it also fails for e.g. YEAH (should be YEeeAaaH). \$\endgroup\$
    – Neil
    May 19 at 8:45
  • \$\begingroup\$ @Neil Can regex lookaheads/behinds be used for the transliterate regex? Or can the transliterate limit not be applied to the entire string, but only to each individual match? Or can we apply the transliterate in a reverse order to the string? \$\endgroup\$ May 19 at 9:02
  • \$\begingroup\$ @Neil This works, but is even longer.. :/ I would like to apply the r (RightToLeft) mode to the transliterate somehow.. \$\endgroup\$ May 19 at 9:07
  • 1
    \$\begingroup\$ The second limit applies to each individual match of a transliteration, so you can write 0T1>`L`l`([AEIOU])\1\1 to transliterate all characters after the first of each match, thus saving a byte over my previous approaches of T`L`l`([AEIOU])\1(?!\1) and rT`L`l`(?<=\1)([AEIOU]). But maybe you can combine the latter with your suggestion to get down to 42 bytes? \$\endgroup\$
    – Neil
    May 19 at 12:33
  • 1
    \$\begingroup\$ Whoops, yes, I miscounted, I had that very 43 byte solution in mind. (But Tr works; maybe your \1 was in the wrong place at the time?) \$\endgroup\$
    – Neil
    May 19 at 18:23
2
\$\begingroup\$

V (vim), 34 bytes

:%s/\v([aeiouAEIOU])\1*/\1\L\1\1/g

Try it online!

Very similar to other regex based solutions.

\$\endgroup\$
2
\$\begingroup\$

C (gcc), 125 121 119 bytes

  • -2 thanks to ceilingcat

Scans for vowels and coalesces duplicates, lowercasing the extra output vowels.

i,c;f(char*s){for(;c=*s++;){if(index("aeiou",c|32)){for(;i=c==*s;s++);for(;i<3;)putchar(c|!!i++*32);}else putchar(c);}}

Try it online!

\$\endgroup\$
0
1
\$\begingroup\$

Charcoal, 29 bytes

FS¿¬⁼ιψ«ι≔ωψ¿№AEIOU↥ι«≔ιψ↧ι↧ι

Try it online! Link is to verbose version of code. Explanation:

FS

Loop over the characters of the input string.

¿¬⁼ιψ«

If this is not a duplicate vowel, then:

ι

Output the current character.

≔ωψ

Clear the last duplicate vowel.

¿№AEIOU↥ι«

If this is a vowel, then:

≔ιψ

Store the last vowel.

↧ι↧ι

Output the lowercased vowel twice.

\$\endgroup\$

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.