Skip to main content
Edit header for leaderboard snippet.
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

PHP, (171 152 134 125)

function f($s){while(!$a&&++$i<strlen($s))for($j=0;$b=substr($s,$j++,$i);)strpos($s,$b)==strrpos($s,$b)&&($a[]=$b);return$a;}

http://3v4l.org/RaWTN

PHP (171 152 134 125)

function f($s){while(!$a&&++$i<strlen($s))for($j=0;$b=substr($s,$j++,$i);)strpos($s,$b)==strrpos($s,$b)&&($a[]=$b);return$a;}

http://3v4l.org/RaWTN

PHP, 171 152 134 125

function f($s){while(!$a&&++$i<strlen($s))for($j=0;$b=substr($s,$j++,$i);)strpos($s,$b)==strrpos($s,$b)&&($a[]=$b);return$a;}

http://3v4l.org/RaWTN

Improve
Source Link
Stephen
  • 201
  • 1
  • 4

PHP (171 152 134134 125)

function f($s){$l=strlenwhile(!$a&&++$i<strlen($s);while(!$a&&++$i<$l)for($j=0;$j<$l;)strpos($s,$b=substr$j=0;$b=substr($s,$j‌​++$j++,$i);)strpos($s,$b)==strrpos($s,$b)&&($a[]=$b);return$a;}

http://3v4l.org/DEVvVhttp://3v4l.org/RaWTN

PHP (171 152 134)

function f($s){$l=strlen($s);while(!$a&&++$i<$l)for($j=0;$j<$l;)strpos($s,$b=substr($s,$j‌​++,$i))==strrpos($s,$b)&&($a[]=$b);return$a;}

http://3v4l.org/DEVvV

PHP (171 152 134 125)

function f($s){while(!$a&&++$i<strlen($s))for($j=0;$b=substr($s,$j++,$i);)strpos($s,$b)==strrpos($s,$b)&&($a[]=$b);return$a;}

http://3v4l.org/RaWTN

Improve
Source Link
Stephen
  • 201
  • 1
  • 4

PHP (171 152152 134)

function f($s){$l=strlen($s);while(!$a&&++$i<$l)for($j=0;$j<$l&&($j=0;$j<$l;)strpos($s,$b=substr($s,$j++$j‌​++,$i))||1)&&(strpos($s,$b)==strrpos($s,$b)&&($a[]=$b)||1););return$a;}

http://3v4l.org/S1mbL

If outputting an array of the empty string is required for the empty string input, goes back to 171: http://3v4l.org/guTWJhttp://3v4l.org/DEVvV

PHP (171 152)

function f($s){$l=strlen($s);while(!$a&&++$i<$l)for($j=0;$j<$l&&(($b=substr($s,$j++,$i))||1)&&(strpos($s,$b)==strrpos($s,$b)&&($a[]=$b)||1););return$a;}

http://3v4l.org/S1mbL

If outputting an array of the empty string is required for the empty string input, goes back to 171: http://3v4l.org/guTWJ

PHP (171 152 134)

function f($s){$l=strlen($s);while(!$a&&++$i<$l)for($j=0;$j<$l;)strpos($s,$b=substr($s,$j‌​++,$i))==strrpos($s,$b)&&($a[]=$b);return$a;}

http://3v4l.org/DEVvV

Improved formatting
Source Link
ProgramFOX
  • 8.3k
  • 7
  • 45
  • 70
Loading
Improve
Source Link
Stephen
  • 201
  • 1
  • 4
Loading
Source Link
Stephen
  • 201
  • 1
  • 4
Loading