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

Implement val's suggestion
Source Link

Lua, (削除) 67 (削除ここまで) (削除) 66 (削除ここまで) (削除) 63 (削除ここまで) (削除) 59 (削除ここまで) 33(削除) 33 (削除ここまで) 32 bytes

-25 bytes thanks to Giuseppe
-1 byte thanks to val

print(#arg[1]#(...):gsub("(.)%1","")<1)

Try it online! Try it online!

Removes every doubled character, then checks if the result is empty.

Lua, (削除) 67 (削除ここまで) (削除) 66 (削除ここまで) (削除) 63 (削除ここまで) (削除) 59 (削除ここまで) 33 bytes

-25 bytes thanks to Giuseppe

print(#arg[1]:gsub("(.)%1","")<1)

Try it online!

Removes every doubled character, then checks if the result is empty.

Lua, (削除) 67 (削除ここまで) (削除) 66 (削除ここまで) (削除) 63 (削除ここまで) (削除) 59 (削除ここまで) (削除) 33 (削除ここまで) 32 bytes

-25 bytes thanks to Giuseppe
-1 byte thanks to val

print(#(...):gsub("(.)%1","")<1)

Try it online!

Removes every doubled character, then checks if the result is empty.

Implements Giuseppe's solution
Source Link

Lua, (削除) 67 (削除ここまで) (削除) 66 (削除ここまで) (削除) 63 (削除ここまで) 59(削除) 59 (削除ここまで) 33 bytes

-25 bytes thanks to Giuseppe

i=arg[1]for j=1,#i do i=iprint(#arg[1]:gsub("^"(.)%1","")end print(i==""<1)

Try it online! Try it online!

Removes the first two characters if they'reevery doubled character, then checks if the result is empty. Did a bit of a cheese by making the loop run for each character of input.

Lua, (削除) 67 (削除ここまで) (削除) 66 (削除ここまで) (削除) 63 (削除ここまで) 59 bytes

i=arg[1]for j=1,#i do i=i:gsub("^(.)%1","")end print(i=="")

Try it online!

Removes the first two characters if they're doubled, then checks if the result is empty. Did a bit of a cheese by making the loop run for each character of input.

Lua, (削除) 67 (削除ここまで) (削除) 66 (削除ここまで) (削除) 63 (削除ここまで) (削除) 59 (削除ここまで) 33 bytes

-25 bytes thanks to Giuseppe

print(#arg[1]:gsub("(.)%1","")<1)

Try it online!

Removes every doubled character, then checks if the result is empty.

TIL that i:len() can be replaced with #i. Who would've thunk
Source Link

Lua, (削除) 67 (削除ここまで) (削除) 66 (削除ここまで) 63(削除) 63 (削除ここまで) 59 bytes

i=arg[1]whilei=arg[1]for i~=jj=1,#i do j=i;i=ii=i:gsub("^(.)%1","")end;printend print(i=="")

Try it online! Try it online!

Reads input, clones to another variable, then replaces every instance ofRemoves the first two characters repeating, while checking that both "offset" variables are equal. This will only be true when it can no longer find a pair of characters at the start (so either it's no longer double speakif they're doubled, or it finished the job). Prints truethen checks if the final result is empty.


# [Lua], (削除) 66 (削除ここまで) 63 bytes
i=arg[1]for k in i:gmatch("(.)%1")do i=i:sub(3)end print(i=="")

Try it online!

Similar to the previous version, but with Did a slightly different approach (for loop that substrings, rather than whilebit of a cheese by making the loop with gsub)run for each character of input.

Lua, (削除) 67 (削除ここまで) (削除) 66 (削除ここまで) 63 bytes

i=arg[1]while i~=j do j=i;i=i:gsub("^(.)%1","")end;print(i=="")

Try it online!

Reads input, clones to another variable, then replaces every instance of the first two characters repeating, while checking that both "offset" variables are equal. This will only be true when it can no longer find a pair of characters at the start (so either it's no longer double speak, or it finished the job). Prints true if the final result is empty.


# [Lua], (削除) 66 (削除ここまで) 63 bytes
i=arg[1]for k in i:gmatch("(.)%1")do i=i:sub(3)end print(i=="")

Try it online!

Similar to the previous version, but with a slightly different approach (for loop that substrings, rather than while loop with gsub).

Lua, (削除) 67 (削除ここまで) (削除) 66 (削除ここまで) (削除) 63 (削除ここまで) 59 bytes

i=arg[1]for j=1,#i do i=i:gsub("^(.)%1","")end print(i=="")

Try it online!

Removes the first two characters if they're doubled, then checks if the result is empty. Did a bit of a cheese by making the loop run for each character of input.

Didn't know using arguments rather than input was valid
Source Link
Loading
Reduced original answer, included a similar alternative
Source Link
Loading
Source Link
Loading

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