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 Answer

deleted 920 characters in body
Source Link
naffetS
  • 13.1k
  • 2
  • 22
  • 54

Vyxal s, 1712 bytes

Ṙ⌈ḣǐJ ̈2∷‛_ṫ$RǐR5‛_-iJ;ṅṪṘẎYp

Try it Online! Try it Online!

-5 bytes thanks to emanresuA

How?

ṫ$RǐR5‛_-ẎYp
ṫ # Tail extract, push a[:-1] and a[-1]
 $ # Swap
 R # Reverse each
 ǐ # Capitalize first letter of each
 R # Reverse each
 5 # Push length without popping
 ‛_- # Push "_-"
 Ẏ # Extend this string to the length
 Y # Interleave the list of words and each character of this string together
 p # Append the last item of the input (pushed earlier by tail extract) to this list
 # s flag joins this list to a string

Vyxal, 17 bytes

Ṙ⌈ḣǐJ ̈2∷‛_-iJ;ṅṪṘ

Try it Online!

Vyxal s, 12 bytes

ṫ$RǐR5‛_-ẎYp

Try it Online!

-5 bytes thanks to emanresuA

How?

ṫ$RǐR5‛_-ẎYp
ṫ # Tail extract, push a[:-1] and a[-1]
 $ # Swap
 R # Reverse each
 ǐ # Capitalize first letter of each
 R # Reverse each
 5 # Push length without popping
 ‛_- # Push "_-"
 Ẏ # Extend this string to the length
 Y # Interleave the list of words and each character of this string together
 p # Append the last item of the input (pushed earlier by tail extract) to this list
 # s flag joins this list to a string
deleted 920 characters in body
Source Link
naffetS
  • 13.1k
  • 2
  • 22
  • 54

Vyxal, 2017 bytes

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

Try it Online!

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

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

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

Vyxal, 17 bytes

Ṙ⌈ḣǐJ ̈2∷‛_-iJ;ṅṪṘ

Try it Online!

added 77 characters in body
Source Link
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

Vyxal, 20 bytes

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

Try it Online!

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
deleted 741 characters in body
Source Link
naffetS
  • 13.1k
  • 2
  • 22
  • 54
Loading
Source Link
naffetS
  • 13.1k
  • 2
  • 22
  • 54
Loading

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