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

-4 bytes thx to @Night2!
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61

PHP, (削除) 58 (削除ここまで) 56 bytes

function f($s){return!$s?:$s[0]==$s[1]&f(substr($s,2));}

Try it online!

As a recursive function.

PHP, (削除) 61 (削除ここまで) 56(削除) 56 (削除ここまで) 52 bytes

foreach(str_splitwhile($argn,2)as$a''<$l=$argn[$i++])$r|=$a[0]$r|=$l!=$a[1];echo=$argn[$i++];echo!$r;

Try it online! Try it online!

Or standalone program. Input string via STDIN, output is truthy (1) if it is double speak, and falsey (0) if it is not double speak.

-4 bytes thx to @Night2 !

PHP, (削除) 58 (削除ここまで) 56 bytes

function f($s){return!$s?:$s[0]==$s[1]&f(substr($s,2));}

Try it online!

As a recursive function.

PHP, (削除) 61 (削除ここまで) 56 bytes

foreach(str_split($argn,2)as$a)$r|=$a[0]!=$a[1];echo!$r;

Try it online!

Or standalone program. Input string via STDIN, output is truthy (1) if it is double speak, and falsey (0) if it is not double speak.

PHP, (削除) 58 (削除ここまで) 56 bytes

function f($s){return!$s?:$s[0]==$s[1]&f(substr($s,2));}

Try it online!

As a recursive function.

PHP, (削除) 61 (削除ここまで) (削除) 56 (削除ここまで) 52 bytes

while(''<$l=$argn[$i++])$r|=$l!=$argn[$i++];echo!$r;

Try it online!

Or standalone program. Input string via STDIN, output is truthy (1) if it is double speak, and falsey (0) if it is not double speak.

-4 bytes thx to @Night2 !

-2 bytes for recursive
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61

PHP, (削除) 58 (削除ここまで) 56 bytes

function f($s){return!$s?:$s[0]==$s[1]&f(substr($s,2));}

Try it online!

As a recursive function.

PHP , (削除) 61 (削除ここまで) 56 bytes

foreach(str_split($argn,2)as$a)$r|=$a[0]!=$a[1];echo!$r;

Try it online! Try it online!

InputOr standalone program. Input string via STDIN, output is truthy (1) if it is double speak, and falsey (0) if it is not double speak.

PHP , 58 bytes

Or recursive:

function f($s){return$s?$s[0]==$s[1]?f(substr($s,2)):0:1;}

Try it online!

PHP, (削除) 61 (削除ここまで) 56 bytes

foreach(str_split($argn,2)as$a)$r|=$a[0]!=$a[1];echo!$r;

Try it online!

Input string via STDIN, output is truthy (1) if it is double speak, and falsey (0) if it is not double speak.

PHP , 58 bytes

Or recursive:

function f($s){return$s?$s[0]==$s[1]?f(substr($s,2)):0:1;}

Try it online!

PHP, (削除) 58 (削除ここまで) 56 bytes

function f($s){return!$s?:$s[0]==$s[1]&f(substr($s,2));}

Try it online!

As a recursive function.

PHP , (削除) 61 (削除ここまで) 56 bytes

foreach(str_split($argn,2)as$a)$r|=$a[0]!=$a[1];echo!$r;

Try it online!

Or standalone program. Input string via STDIN, output is truthy (1) if it is double speak, and falsey (0) if it is not double speak.

add recursive answer
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61

PHP, (削除) 61 (削除ここまで) 56 bytes

foreach(str_split($argn,2)as$a)$r|=$a[0]!=$a[1];echo!$r;

Try it online!

Input string via STDIN, output is truthy (1) if it is double speak, and falsey (0) if it is not double speak.

PHP , 58 bytes

Or recursive:

function f($s){return$s?$s[0]==$s[1]?f(substr($s,2)):0:1;}

Try it online!

PHP, (削除) 61 (削除ここまで) 56 bytes

foreach(str_split($argn,2)as$a)$r|=$a[0]!=$a[1];echo!$r;

Try it online!

Input string via STDIN, output is truthy (1) if it is double speak, and falsey (0) if it is not double speak.

PHP, (削除) 61 (削除ここまで) 56 bytes

foreach(str_split($argn,2)as$a)$r|=$a[0]!=$a[1];echo!$r;

Try it online!

Input string via STDIN, output is truthy (1) if it is double speak, and falsey (0) if it is not double speak.

PHP , 58 bytes

Or recursive:

function f($s){return$s?$s[0]==$s[1]?f(substr($s,2)):0:1;}

Try it online!

-5 bytes, shorter, less buggy approach
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61
Loading
Rollback to Revision 4
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61
Loading
-7 bytes, shorter, less buggy approach
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61
Loading
+1 byte single char input bug
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61
Loading
fix check for last group, return 1 for true, 0 for false
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61
Loading
added 208 characters in body
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61
Loading
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61
Loading

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