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

added 458 characters in body
Source Link
GammaFunction
  • 7.1k
  • 14
  • 24

Zsh, 6765 bytes

-4 bytes thanks to @pxeger, -2 bytes thanks to @roblogic

forrepeat ((;#1;))echo&&for$#1;echo&&for y ({A..-Z})printf ${(Ml:1:)1[1]%$y}&&1=${1#$y}

(削除) Try it online! Try it online! (削除ここまで) Try it online! Try it online!

Append to $s a (M) matched letter, (l:1:) left-padded to one character, then remove the letter if it matches the start of 1ドル.

Zsh, 67 bytes

-4 bytes thanks to @pxeger

for ((;#1;))echo&&for y ({A..Z})printf ${(Ml:1:)1[1]%$y}&&1=${1#$y}

(削除) Try it online! (削除ここまで) Try it online!

Append to $s a (M) matched letter, (l:1:) left-padded to one character, then remove the letter if it matches the start of 1ドル.

Zsh, 65 bytes

-4 bytes thanks to @pxeger, -2 bytes thanks to @roblogic

repeat $#1;echo&&for y ({A-Z})printf ${(Ml:1:)1[1]%$y}&&1=${1#$y}

(削除) Try it online! Try it online! (削除ここまで) Try it online!

Append to $s a (M) matched letter, (l:1:) left-padded to one character, then remove the letter if it matches the start of 1ドル.

added 178 characters in body
Source Link
GammaFunction
  • 7.1k
  • 14
  • 24

Zsh, 6867 bytes

-34 bytes thanks to @pxeger

for ((;#1;)){s=
forecho&&for y ({A..Z})s+=$printf ${(Ml[1]Ml:1:)1[1]%$y}&&1=${1#$y}
<<<$s}

(削除) Try it online! (削除ここまで) Try it online! Try it online!

Append to $s a(M) matched letter, padded(l:1:) left-padded to one character, in one statement, then removingremove the letter if it matches from the frontstart of 1ドル.

Zsh, 68 bytes

-3 bytes thanks to @pxeger

for ((;#1;)){s=
for y ({A..Z})s+=${(Ml[1])1[1]%$y}&&1=${1#$y}
<<<$s}

(削除) Try it online! (削除ここまで) Try it online!

Append to $s a matched letter, padded to one character, in one statement, then removing the letter if it matches from the front of 1ドル.

Zsh, 67 bytes

-4 bytes thanks to @pxeger

for ((;#1;))echo&&for y ({A..Z})printf ${(Ml:1:)1[1]%$y}&&1=${1#$y}

(削除) Try it online! (削除ここまで) Try it online!

Append to $s a(M) matched letter, (l:1:) left-padded to one character, then remove the letter if it matches the start of 1ドル.

deleted 197 characters in body
Source Link
GammaFunction
  • 7.1k
  • 14
  • 24

Two tied solutions:

Zsh, 7168 bytes

for ((;#1;)){s=
for y ({A..Z})((#1==#y))&&s+=$y&&1=${1:1}||s+=\ 
<<<$s}

Try it online!

This uses straightforward comparison/ternary.-3 bytes thanks to @pxeger

Zsh , 71 bytes

for ((;#1;)){s=
for y ({A..Z})s+=${${(MMl[1])1[1]%$y}:-\ }&&1=${1#$y}
<<<$s}

Try it online! (削除) Try it online! (削除ここまで)Try it online!

This is a bit more clever, appendingAppend to s either the$s a matched letter or a space, padded to one character, in one statement, then removing athe letter if it matches from the front of 1ドル.

Two tied solutions:

Zsh, 71 bytes

for ((;#1;)){s=
for y ({A..Z})((#1==#y))&&s+=$y&&1=${1:1}||s+=\ 
<<<$s}

Try it online!

This uses straightforward comparison/ternary.

Zsh , 71 bytes

for ((;#1;)){s=
for y ({A..Z})s+=${${(M)1[1]%$y}:-\ }&&1=${1#$y}
<<<$s}

Try it online!

This is a bit more clever, appending to s either the matched letter or a space in one statement, then removing a letter if it matches from the front of 1ドル.

Zsh, 68 bytes

-3 bytes thanks to @pxeger

for ((;#1;)){s=
for y ({A..Z})s+=${(Ml[1])1[1]%$y}&&1=${1#$y}
<<<$s}

(削除) Try it online! (削除ここまで)Try it online!

Append to $s a matched letter, padded to one character, in one statement, then removing the letter if it matches from the front of 1ドル.

Source Link
GammaFunction
  • 7.1k
  • 14
  • 24
Loading

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