Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

3 of 5
added 77 characters in body
naffetS
  • 13.1k
  • 2
  • 22
  • 54

Vyxal, 20 bytes

⌈ṫ$ƛṫ⇧J;p ̈2∷‛_-iJ;ṅṪ

Try it Online!

ƛṫ⇧J; could also be (⇧uvV, and ̈2∷‛_-iJ; could also be ‡1-ẇ‡\_JẆ.

How?

⌈ṫ$ƛṫ⇧J;p ̈2∷‛_-iJ;ṅṪ
⌈ # Split on spaces
 ṫ # Tail extract; push a[:-1] and a[-1]
 $ # Swap
 ƛ # For each:
 ṫ # Tail extract; push a[:-1] and a[-1]
 ⇧ # Uppercase
 J # Join together again
 ; # Close map lambda
 p # Append the last word again
 ̈2 # Map over this list, pushing both item and (0-based) index:
 ∷ # Modulo the index by 2
 ‛_-i # Index that into the string "_-"
 J # Append that to the word
 ; # Close mapping lambda
 ṅ # Join this list together
 Ṫ # Remove the last character
naffetS
  • 13.1k
  • 2
  • 22
  • 54

AltStyle によって変換されたページ (->オリジナル) /