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

use l.char instead of string.char
Source Link
anderium
  • 613
  • 5
  • 9

Lua, 9994 bytes

function r(l)return l:find"[` ]"and"\n"or l..r(stringl.char(l:byte()-1))end
print((...):gsub(".",r))

Try it online! Try it online!

Only works if we can have redundant output, else +1 byte.

Explanation

Creates a recursive function r that returns what each letter should turn into. When the input letter of this function is a space or the character before a (which is `) then this should not be printed, but a new line instead.

Replace each character in the input string (the first command-line argument) with the output of the function r called with this character.

Lua, 99 bytes

function r(l)return l:find"[` ]"and"\n"or l..r(string.char(l:byte()-1))end
print((...):gsub(".",r))

Try it online!

Only works if we can have redundant output, else +1 byte.

Explanation

Creates a recursive function r that returns what each letter should turn into. When the input letter of this function is a space or the character before a (which is `) then this should not be printed, but a new line instead.

Replace each character in the input string (the first command-line argument) with the output of the function r called with this character.

Lua, 94 bytes

function r(l)return l:find"[` ]"and"\n"or l..r(l.char(l:byte()-1))end
print((...):gsub(".",r))

Try it online!

Only works if we can have redundant output, else +1 byte.

Explanation

Creates a recursive function r that returns what each letter should turn into. When the input letter of this function is a space or the character before a (which is `) then this should not be printed, but a new line instead.

Replace each character in the input string (the first command-line argument) with the output of the function r called with this character.

Source Link
anderium
  • 613
  • 5
  • 9

Lua, 99 bytes

function r(l)return l:find"[` ]"and"\n"or l..r(string.char(l:byte()-1))end
print((...):gsub(".",r))

Try it online!

Only works if we can have redundant output, else +1 byte.

Explanation

Creates a recursive function r that returns what each letter should turn into. When the input letter of this function is a space or the character before a (which is `) then this should not be printed, but a new line instead.

Replace each character in the input string (the first command-line argument) with the output of the function r called with this character.

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