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

Post Undeleted by cnamejj
Fixed bug, original code didn't meet all the rules.
Source Link
cnamejj
  • 2.9k
  • 10
  • 11

Ly, 25(削除) 25 (削除ここまで) 37 bytes

irsp['i0"_-"rsp[' =:' *lf-o'?*+sp]loo[Ifprfr0]psp]>lo

Try it online! Try it online!

Revised code... I didn't read the rule saying space has to be translated to - and _ alternating.

iri  - read inpinput as codepoints on0"_-" stack, - push "0" and delimiters
 r - reverse stack
 sp - stash the first char,- thensave last and delete
 [ ] p]  - loopsloop over the 2-N chars on the stack
 ' = - push 0|1 from comparing curr char to " "
 : - copy the - duplicate result
 ' * - multiply result w/ " " (32) 
 lf - pull prev char, flip top stack entries
 - - capitalizes if the curr char is " "
 o - write out char codepoint as a char
 '? [ 0]p - load 63 (diff between - if/then, true if " " andis "_")curr char
 * I  - multiplecopy bysecond "isto space"bottom boolean
stack entry  fp + - convertspull " " charsforward, todelete
 "_" rfr - reverse bottom two entries
 sp s - stash the"_" curror char"-"
 and delete from stack
 lo > - printswitch thestacks
 last char (pulled up backup cell) lo - load last char and print

Ly, 25 bytes

irsp[' =:' *lf-o'?*+sp]lo

Try it online!

ir - read inp as codepoints on stack, reverse
 sp - stash the first char, then delete
 [ ] - loops over the 2-N chars on the stack
 ' = - push 0|1 from comparing curr char to " "
 : - copy the result
 ' * - multiply result w/ " " (32) 
 lf - pull prev char, flip top stack entries
 - - capitalizes if the curr char is " "
 o - write out char codepoint as a char
 '? - load 63 (diff between " " and "_")
 * - multiple by "is space" boolean
 + - converts " " chars to "_"
 sp - stash the curr char and delete from stack
 lo - print the last char (pulled up backup cell)

Ly, (削除) 25 (削除ここまで) 37 bytes

i0"_-"rsp[' =:' *lf-o[Ifprfr0]psp]>lo

Try it online!

Revised code... I didn't read the rule saying space has to be translated to - and _ alternating.

i  - read input as codepoints 0"_-" - push "0" and delimiters
 r - reverse stack
 sp - save last and delete
 [ p]  - loop over the 2-N chars ' = - push 0|1 from comparing curr char to " "
 :  - duplicate result
 ' * - multiply result w/ " " (32) 
 lf - pull prev char, flip top stack entries
 - - capitalizes if the curr char is " "
 o - write out char codepoint as a char
 [ 0]p  - if/then, true if " " is curr char
 I  - copy second to bottom stack entry  fp - pull " " forward, delete
  rfr - reverse bottom two entries
 s - stash "_" or "-"
 > - switch stacks
  lo - load last char and print
Post Deleted by cnamejj
Source Link
cnamejj
  • 2.9k
  • 10
  • 11

Ly, 25 bytes

irsp[' =:' *lf-o'?*+sp]lo

Try it online!

ir - read inp as codepoints on stack, reverse
 sp - stash the first char, then delete
 [ ] - loops over the 2-N chars on the stack
 ' = - push 0|1 from comparing curr char to " "
 : - copy the result
 ' * - multiply result w/ " " (32) 
 lf - pull prev char, flip top stack entries
 - - capitalizes if the curr char is " "
 o - write out char codepoint as a char
 '? - load 63 (diff between " " and "_")
 * - multiple by "is space" boolean
 + - converts " " chars to "_"
 sp - stash the curr char and delete from stack
 lo - print the last char (pulled up backup cell)

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