g | x | w | all
Bytes Lang Time Link
055AWK250807T163148Zxrs
017Uiua231105T212309Zchunes
035APOL220106T173705ZGinger
nanJavascript220102T092832Zatzlt
065Factor220207T034305Zchunes
142Headascii220206T214432Zthejonym
01105AB1E220105T183623ZKevin Cr
041Ruby220104T110724Zdaniero
086Python 2220102T071538ZU13-Forw
123SNOBOL4 CSNOBOL4220102T191426ZGiuseppe
022x86 / x8664 machine code220103T184510ZPeter Co
3331J220102T233605ZJonah
014Jelly220102T155948Zlynn
019BQN220102T110451ZRazetime
058Python220102T072327Zpxeger
061C gcc220102T103833Zdingledo
057R220102T194622ZDominic
094R220102T125535ZMaë
065R220102T191837Zpajonk
010Japt v2.0a0220102T182618ZShaggy
111C tcc220102T163629ZFinxx
081Lua220102T162032ZLuatic
025Retina 0.8.2220102T121206ZNeil
039APL+WIN220102T092932ZGraham
021Charcoal220102T083417ZNeil
023Dyalog APL220102T083533ZAdá
017Retina220102T081906ZNeil
009Vyxal220102T075406Zlyxal
023Perl 5220102T072718ZDom Hast
013Jelly220102T072339Zhyperneu

AWK, 55 bytes

{for(;i++<NF;)printf$i~/[aeiou]/&&z++%2?toupper($i):$i}

Attempt This Online!

Uiua, 17 bytes

-×32×\≠.∊,"aeiou"

Try it!

Port of Razetime's BQN answer.

-×32×\≠.∊,"aeiou"
        ∊,"aeiou"  # mask of where vowels are in input
       .           # duplicate
     \≠            # inequality scan
    ×              # multiply
 ×32               # multiply by 32
-                  # subtract (capitalize)

APOL, 35 bytes

j(ƒ(i ¿(&(c(Ⓔ ↓(∋)) ≐(∈)) ∋ ↑(∋))))

Explanation

j(  Join a list to a string
  ƒ(  Listbuilder for
    i  Input
    ¿(  Returning if (called for each item in the input)
      &(  And (condition)
        c(  String contains
          Ⓔ  The constant string "aeiou"
          ↓(  To lowercase
            ∋  Current character
          )
        )
        ≐(  Is even
          ∈  For loop counter
        )
      )
      ∋  For loop item (executed if true)
      ↑(  To uppercase
        ∋  For loop item
      )
    )
  )
)

Javascript, 57 5654 bytes

s=>s.replace(/[aeiou]/g,c=>(s=!s)?c.toUpperCase():c)

-1 Thanks to Patrick Stephansen.
-2 Thanks to tsh. -2 Thanks to l4m2.

Usage:

console.log((s=>s.replace(/[aeiou]/g,c=>(s=!s)?c.toUpperCase():c)))("string goes here"))

Try it online

Factor, 65 bytes

[ dup [ "aeiou"in? ] arg-where <odds> over [ 32 - ] change-nths ]

Try it online!

Explanation

Get the indices of the vowels from the input, take the odd-indexed elements of those, then subtract 32 from the input at those indices. change-nths is a mutating word which has the usual ( indices seq -- ) stack effect which is why we need an extra copy on the stack before we call it.

                          ! "abcdefghijklmnopqrstuvwxyz"
dup                       ! "abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz"
[ "aeiou"in? ] arg-where  ! "abcdefghijklmnopqrstuvwxyz" V{ 0 4 8 14 20 }
<odds>                    ! "abcdefghijklmnopqrstuvwxyz" { 4 14 }
over                      ! "abcdefghijklmnopqrstuvwxyz" { 4 14 } "abcdefghijklmnopqrstuvwxyz"
[ 32 - ] change-nths      ! "abcdEfghijklmnOpqrstuvwxyz"

Headascii, 142 bytes

----[]]]][]][++++^^^^D^^^^^+^{{D^(U):++++(R):++++(R):++++++(R):++++++(R):R()+E:P};RP{D^(U):++++(R):++++(R):++++++(R):++++++(R):R()+E:P};R]P}.!

Try it here! Code will have to be copied, and executed like this:

erun("----[]]]][]][++++^^^^D^^^^^+^{{D^(U):++++(R):++++(R):++++++(R):++++++(R):R()+E:P};RP{D^(U):++++(R):++++(R):++++++(R):++++++(R):R()+E:P};R]P}.!","your input")

This one was fun, not sure if there's any room for serious golfing without a different approach. Maybe something with an oscillator to decide whether to uppercase a given vowel? But the 3 main storage registers are used up for comparison, storing -32 (uppercase constant), and storing 97 (ascii a, first vowel). So I'm not sure where the constant would be held. I'll take another whack at it sometime though.

----[]]]][]][++++^^^^D^^^^^+^ Constants -32 and 97
----                          -4
    []]]]                     *4
         []][                 *2, and store
             ++++             4
                 ^^^^         *4
                     D^^^^^+^ *6+1, already stored

{{...};RP{...};R]P}. The rest of block 0
{                 }  Loop
 {   }               Loop until a vowel is found
      ;RP            Concatenate it to the string register
         {   }       Loop until a vowel is found
              ;R]P   Subtract 32 (uppercase) and concatenate to string register
                   . Block separator

{D^(U):++++(R):++++(R):++++++(R):++++++(R):R()+E:P} First loop
{                                                 } Loop
 D^(U)                                              If byte is "a",
       ++++(R)                                      "e"
               ++++(R)                              "i"
                       ++++++(R)                    "o"
                                 ++++++(R)          or "u",
      :       :       :         :         :           Exit loop.
                                                    Else,
                                           R()        If byte is null (i.e. string ended)
                                              +E        Go to block 1
                                                :     Else,
                                                 P      Concatenate byte to string register

{D^(U):++++(R):++++(R):++++++(R):++++++(R):R()+E:P} Second Loop is identical to the first
                                                    Avoiding two identical loops would be
                                                    a major golfing opportunity

!  Block 1
!  Print string register, end of execution

05AB1E, 11 bytes

žMÃDεNÉiu]‡

Try it online.

Or alternatively the εNÉiu] could be 2ι`u.ι.

Try it online.

Explanation:

žM         # Push the constant "aeiou"
  Ã        # Only keep those letters from the (implicit) input
   D       # Duplicate it
    ε      # Map the vowels in the copy to:
     NÉi   #  If the 0-based index is odd:
        u  #   Uppercase the vowel
    ]      # Close the if-statement and map
     ‡     # Transliterate the lowercase vowels to the alternating cased vowels
           # in the (implicit) input
           # (after which the result is output implicitly)

    2ι     # Uninterleave into two parts
      `    # Pop and push both parts separated to the stack
       u   # Uppercase the second part
        .ι # And interleave the two parts back again (to a list of characters)

Ruby, 41 bytes

Uses the -p flag.

i=1
gsub(/[aeiou]/){[$&,$&.upcase][i^=1]}

Try it online!

Python 2, 86 bytes

-26 thanks to ElPedro.

-2 thanks to Daniel.

c,S=0,''
for i in input():
 if i in'aeiou':S+=(i,i.upper())[c];c^=1
 else:S+=i
print S

Try it online

SNOBOL4 (CSNOBOL4), 148 123 bytes

	S =INPUT
N	S ARB . L ANY('aeiou') . C REM . S	:F(O)
	X =1 - X
	C =CHAR(ORD(C) - 32) EQ(X)
	O =O L C	:(N)
O	OUTPUT =O S
END

Try it online!

Explanation:

	S =INPUT			;* Read input
N	S ARB . L ANY('aeiou') . C REM . S	:F(O)
					;* Match in S:
					;* ARBitrary string (store as L), ANY single vowel (store as C)
					;* and the REMainder of the string (store as S).
					;* If there is no match, goto O.
	X =1 - X			;* Set X (initially treated as 0) to 1-X.
	C =CHAR(ORD(C) - 32) EQ(X)	;* if X == 0, set C to uppercase, otherwise do nothing.
	O =O L C	:(N)		;* append to O L and C, then goto N.
O	OUTPUT =O S			;* Output updated string
END

x86 / x86-64 machine code, 22 bytes

Takes pointer (RSI), length (RCX) in registers, modifies the string in-place. Callable from C with the x86-64 SysV calling convention as void vowel_alt_caseflip(int dummy, char *RSI, int dummy, size_t RCX). Same machine code works in 32-bit mode, although none of the standard 32-bit C calling conventions match.

NASM listing, with address, machine-code bytes, and source the machine-code answer was generated from.

     1                         ;;; char *str /* RSI */,  size_t len /* RCX */
     2                         vowel_alt_caseflip:
     3 00000000 BF22822000         mov edi, 0x0208222      ; ASCII vowel bitmap, 1-indexed like ASCII codes are with 'a' = 0x61 not 0x60
     4 00000005 31D2               xor edx, edx            ; first vowel is not flipped
     5                         .loop:
     6 00000007 AC                 lodsb                   ; al = *str++
     7 00000008 0FA3C7             bt  edi, eax            ; if (bitmap & (1<<(al&31)))
     8 0000000B 7306               jnc .non_vowel
     9 0000000D 3056FF             xor [rsi-1], dl         ; caseflip or not the current character
    10 00000010 80F220             xor dl, 0x20            ; toggle state for the next
    11                         .non_vowel:
    12 00000013 E2F2               loop  .loop
    13 00000015 C3                 ret

; next address is 0x16, size is 0x16 = 22 bytes

Since the input string is guaranteed to be all lowercase alphabetic, I just used XOR instead of AND with ~0 / ~0x20 to flip instead of clear the ASCII lower-case bit. It would work out to the same size with mov dl, 0xFF / and [rsi-1], dl.

Try it online! with a Linux _start caller that passes it the alphabet twice and makes write system calls before/after, so we can see that it correctly treats u as a vowel.

For more about the immediate bitmap strategy, and variations like using it branchlessly, see SO and two of my previous x86 answers:


Alternate version, same size

I had hoped to be able to use xor al, 0x20 to save a byte vs. DL, but we need AL for efficient string-reading via lodsb. (We need a char from the string in a register to use as a source for bt.) We could start with mov there and use stosb to store, but that would have to be separate from a reg-reg XOR or AND, and still doesn't free up AL.

We could use scasb as a 1-byte inc rdi. Using mov dl, [rdi] to start, and saving the -1 in the memory-dest addressing mode, and another byte from xor al, 0x20 short-form, that's break-even for size and worse for efficiency (useless scasb reload). Or similar efficiency in 32-bit mode since we could use inc edi there.

;;; char *str /* RDI */,  size_t len /* RCX */
vowel_alt_caseflip_scasb:
    mov esi, 0x0208222      ; ASCII vowel bitmap, 1-indexed like ASCII codes are with 'a' = 0x61 not 0x60
    xor eax, eax            ; first vowel is not flipped
.loop:
    mov dl, [rdi]
    bt  esi, edx            ; if (bitmap & (1<<(c&31)))
    jnc .non_vowel
    xor [rdi], al           ; caseflip or not the current character
    xor al, 0x20            ; toggle state for the next
.non_vowel:
    scasb                   ; inc rdi   in one byte even on x86-64
    loop  .loop
    ret

J, 33 31 bytes

(>~:/\)@e.&'aeiou'`(,:toupper)}

Try it online!

-2 thanks to Lynn

Kind of shockingly long, but best I could find so far...

Jelly, 14 bytes

e€Øcn\<$a32^OỌ

Try it online!

e€Øc            For each input character: is it in Øc (vowels)?
                This gets a mask with 1s where vowels are, e.g.
                  “b x d e f h i z k o m u p”
                   0 0 0 1 0 0 1 0 0 1 0 1 0

    n\<$        scanl(≠, mask) < mask: This selects every other 1.
                  scanl(≠):  0 0 0 1 1 1 0 0 0 1 1 0 0
                  original:  0 0 0 1 0 0 1 0 0 1 0 1 0
                         <:  0 0 0 0 0 0 1 0 0 0 0 1 0
                
        a32     Replace all 1s by 32.
           ^O   XOR by ord(input string).
             Ọ  chr()

BQN, 19 bytesSBCS

⊢-32×·≠`⊸<∊⟜"aeiou"

Run online!

Textbook use for under, but character arithmetic is much, much shorter. -10 from Marshall, then -3 from Marshall.

Explanation

⊢-32×·≠`⊸<∊⟜"aeiou"
          ∊⟜"aeiou" bitmask of vowels
      ≠`            inequality scan(XOR scan)
        ⊸<          lesser than original bitmask?
  32×·              32 × that
⊢-                  subtract from the input

Python, 73 71 ··· 58 bytes

lambda s,c=0:bytes(a^c|(c:=c^34087456>>a-97&32)for a in s)

Attempt This Online!

Inputs and outputs as a byte string.

Explanation (I use a $ sigil on variables to distinguish them from letters):

C (gcc), 61 bytes

A full program, where input is taken from STDIN.

x;main(c){for(;read(0,&c,1);)putchar('Xz'%c?c:c^x++%2*32);}

Try it online!

Checking for vowels

Vowels are aeiou, which have the corresponding ASCII codes 97,101,105,111,117. The LCM of these numbers is 1484392455, which has the property of being evenly divisible by only the letters aeiou. Therefore, we can say that c is a vowel if 1484392455%c equals 0. We can compress this number by the use of multi-character constants, giving 'Xz\x08\x07'.

C (clang), 48 bytes

As offered by @AZTECCO, a function which takes a wide string as input, and modifies the string in-place.

x;f(*s){for(x=0;*s;)*s++^='Xz'%*s?0:x++%2*32;}

Try it online!

R, 57 bytes

function(s,t=s%in%utf8ToInt("aeiou"))s-t*32*!cumsum(t)%%2

Try it online!

Input is vector of character codes (for comparison to pajonk's answer). Would be 77 bytes with input as string (for comparison to Maël's answer).


Edit: this approach would be only 48 bytes by porting dingledooper's great modulo trick...

R, 94 bytes

-26 bytes thanks to Giuseppe. -2 bytes thanks to Robin Ryder

function(s){s=el(strsplit(s,""))
s[i]=toupper(s[i<-grep("[aeiou]",s)[!1:0]])
Reduce(paste0,s)}

See pajonk's and Dominic van Essen's answers for a clever use of intToUtf8 and utf8ToInt.

Try it online!

R, 65 bytes

function(s){s[i]=s[i<-which(s%in%utf8ToInt("aeiou"))[!1:0]]-32;s}

Try it online!

Takes input and outputs as vectors of char codes.

Some parts borrowed from @Maël's R answer.

Japt v2.0a0, 10 bytes

r\vÈpu gT°

Try it

C (tcc), 174 111 bytes

Saved 63 bytes thanks to manatwork

i,b;f(char*a,int l){for(i=0;i<l;i++)if(a[i]==97||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u')if(b++%2)a[i]-=32;}

Try it online!

Unminified

i, b; 
f(char* a, int l) { 
    for (i = 0; i < l; i++)
        if (a[i] == 97 || a[i] == 'e' || a[i] == 'i' || a[i] == 'o' || a[i] == 'u')
            if (b++ % 2)
                a[i] -= 32; 
}

Lua, 81 bytes

print(((...):gsub("[aeiou]",function(x)u=not u;return u and x or(x):upper()end)))

Try it online!

Expects the input as first argument, prints output. Is one character shorter if return instead of print is used.

Retina 0.8.2, 25 bytes

0T-1=`l`L`(.*?[aeiou]){2}

Try it online! Link includes test cases. Explanation:

(.*?[aeiou]){2}

Match the shortest possible substrings containing two vowels.

-1=

Only transliterate the last character of each match. (The 0 indicates that this modifier applies to the characters of the match rather than the matches themselves.)

T`l`L`

Upper case them.

APL+WIN, 39 bytes

Prompts for string

⎕av[(⎕av⍳s)-32×1=i+i×≠\i←(s←⎕)∊'aeiou']

Index offset from lower to upper case changed in TIO from -32 to +48 to account for differences between APL+WIN and Dyalog atomic vectors.

Try it online!Thanks to Dyalog Classic

Charcoal, 21 bytes

⭆S⎇№aeiouι§⁺↥ιιL⊞Oυιι

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

 S                      Input string
⭆                       Map over characters and join
   №                    Count of
         ι              Current character
    aeiou               In literal string `aeiou`
  ⎇                     If exists then
             ι          Current character
            ↥           Uppercase
           ⁺            Plus
              ι         Current character
          §             Indexed by
                   ι    Current character
                ⊞O      Pushed to
                  υ     Predefined empty list
               L        Length after push
                    ι   Otherwise current character
                        Implicitly print

Dyalog APL, 23 bytes

1∘⎕C@(=\≠⍨)@(∊∘'aeiou')

1∘⎕C uppercase…

@() at…

  =\ XNOR scan (i.e. every other) of the
  ≠⍨ XOR selfie (i.e. all 0s)

@() at…

   member
   of
  'aeiou' vowels

Try APL online!

Retina, 17 bytes

1,2,T`l`L`[aeiou]

Try it online! Link includes test cases. Explanation:

[aeiou]

Match lower case vowels.

1,2,

Only process every other vowel.

T`l`L`

Upper case them.

Although the transliterate command has a shortcut code for vowels, they aren't of any help here so I haven't used them.

Vyxal, 9 bytes

ATy$_⁽⇧¨M

Try it Online!

The power of triads!

Explained

ATy$_⁽⇧¨M
AT       # indices of vowels
  y      # uninterleave into two lists - this pushes a list of every second vowel and every first vowel
   $_    # remove the list of every first vowel
     ⁽⇧¨M # and apply upper-case (a function pushed by ⁽⇧) to those indices (¨M)

Perl 5, 23 bytes

s/[aeiou]/$&^$"x$|--/ge

Try it online!

Explanation

s///ubstitutes each of the lowercase vowels with itself XORed with either 1 or 0 spaces ($" defaults to space) based on $|-- which will alternate each time it's decremented.

Jelly, 13 bytes

e€ØẹTḊm2
Œuç¦

Try It Online!

e€ØẹTḊm2  Helper Link; get every other vowel
e€        For each element, is it in
  Øẹ      the list of vowels ("aeiou")?
    T     Get said indices
     Ḋm2  Pop off the first one and take every other one
Œuç¦      Main Link
   ¦      Apply
Œu        to-uppercase
  ç       to every other vowel