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

added 628 characters in body
Source Link
Dave
  • 161
  • 4

PHP, 195(削除) 195 (削除ここまで) 205 bytes

Added the > 2 character restriction:

<?$a=$argv[1];$r=substr($a,-2,1)=="\n"?strrev($a):$a;foreach(explode("\n",$r)as$l){$s=strlen($l);;$x[$s
$x[$s]=++$i;$m=$i==$s]=++$i;$m=$i==$s?T:M;}$z=count($x);echo$i*$z>2?$z==1&&key($x)==$i?S:($z==1 && $i>2$z==1&&$i>2?R:($i==$z?$m):M)):M;?>

The upside down triangle adds an expensive 56 bytes to this!

Outputs are S,R,T,M

Saved a few bytes thanks to Dom Hastings. Wasted a couple to make it shapely ;)

Try it online! Try it online!

Fixed a few issues now... Test runs produce this.

$_="
$_="
$_""
;say
RESULT:S
=============
$_=
"no
t a
squ
are
";#
RESULT:R
=============
$
_=
"So
this
"."".
shape;
RESULT:T
=============
$_="or
even,
this
way
!!
"
RESULT:T
=============
as
smiley
asd
A
RESULT:M
=============
X
RESULT:M
=============
XX
RESULT:M
=============
cccc
a
aa
cccc
RESULT:M
=============

PHP, 195 bytes

Added the > 2 character restriction:

<?$a=$argv[1];$r=substr($a,-2,1)=="\n"?strrev($a):$a;foreach(explode("\n",$r)as$l){$s=strlen($l);
$x[$s]=++$i;$m=$i==$s?T:M;}$z=count($x);echo$i*$z>2?$z==1&&key($x)==$i?S:($z==1 && $i>2?R:$m):M?>

The upside down triangle adds an expensive 56 bytes to this!

Outputs are S,R,T,M

Saved a few bytes thanks to Dom Hastings. Wasted a couple to make it shapely ;)

Try it online!

PHP, (削除) 195 (削除ここまで) 205 bytes

<?$a=$argv[1];$r=substr($a,-2,1)=="\n"?strrev($a):$a;foreach(explode("\n",$r)as$l){$s=strlen($l);$x[$s
]=++$i;$m=$i==$s?T:M;}$z=count($x);echo$i*$z>2?$z==1&&key($x)==$i?S:($z==1&&$i>2?R:($i==$z?$m:M)):M;?>

The upside down triangle adds an expensive 56 bytes to this!

Outputs are S,R,T,M

Saved a few bytes thanks to Dom Hastings.

Try it online!

Fixed a few issues now... Test runs produce this.

$_="
$_="
$_""
;say
RESULT:S
=============
$_=
"no
t a
squ
are
";#
RESULT:R
=============
$
_=
"So
this
"."".
shape;
RESULT:T
=============
$_="or
even,
this
way
!!
"
RESULT:T
=============
as
smiley
asd
A
RESULT:M
=============
X
RESULT:M
=============
XX
RESULT:M
=============
cccc
a
aa
cccc
RESULT:M
=============
added 56 characters in body
Source Link
Dave
  • 161
  • 4

PHP, 191195 bytes

Added the > 2 character restriction:

<?$a=$argv[1];$r=substr($a,-2,1)=="\n"?strrev($a):$a;foreach(explode("\n",$r)as$l){$s=strlen($l);$x[$s]=++$i;$m=$i==$s;
$x[$s]=++$i;$m=$i==$s?T:M;}$z=count($x);echo$i*$z>2?$z==1&&key($x)==$i?S:($z==1&&$i>2$z==1 && $i>2?R:$m):M;M?>

The upside down triangle adds an expensive 56 bytes to this!

Outputs are S,R,T,M

Saved a few bytes thanks to Dom Hastings. Wasted a couple to make it shapely ;)

Try it online! Try it online!

PHP, 191 bytes

Added the > 2 character restriction:

<?$a=$argv[1];$r=substr($a,-2,1)=="\n"?strrev($a):$a;foreach(explode("\n",$r)as$l){$s=strlen($l);$x[$s]=++$i;$m=$i==$s?T:M;}$z=count($x);echo$i*$z>2?$z==1&&key($x)==$i?S:($z==1&&$i>2?R:$m):M;

The upside down triangle adds an expensive 56 bytes to this!

Outputs are S,R,T,M

Saved a few bytes thanks to Dom Hastings

Try it online!

PHP, 195 bytes

Added the > 2 character restriction:

<?$a=$argv[1];$r=substr($a,-2,1)=="\n"?strrev($a):$a;foreach(explode("\n",$r)as$l){$s=strlen($l);
$x[$s]=++$i;$m=$i==$s?T:M;}$z=count($x);echo$i*$z>2?$z==1&&key($x)==$i?S:($z==1 && $i>2?R:$m):M?>

The upside down triangle adds an expensive 56 bytes to this!

Outputs are S,R,T,M

Saved a few bytes thanks to Dom Hastings. Wasted a couple to make it shapely ;)

Try it online!

deleted 252 characters in body
Source Link
Dave
  • 161
  • 4

PHP, 204191 bytes

Added the > 2 character restriction:

<?$r=substr$a=$argv[1];$r=substr($argv[1]$a,-2,1)=="
"=="\n"?strrev($argv[1]$a):$argv[1];
foreach$a;foreach(explode("
""\n",$r)as$l){$s=strlen($l);$x[$s]=++$i;$m=$i==$s?'T'T:'M';M;}$z=count($x);echo$i*$z>2?$z==1&&key($x)==$i?'S'S:($z==1&&$i>2?'R'R:$m):M;

Original 181 bytes:

<?$r=substr($argv[1],-2,1)=="
"?strrev($argv[1]):$argv[1];
foreach(explode("
",$r)as$l){$s=strlen($l);$x[$s]=++$i;$m=$i==$s?T:M;}$z=count($x);echo $z==1&&key($x)==$i?S:($z==1?R:$m);

The upside down triangle adds an expensive 56 bytes to this!

Outputs are S,R,T,M

Saved a few bytes thanks to Dom Hastings (original was 190 bytes)

Try it online! Try it online!

PHP, 204 bytes

Added the > 2 character restriction:

<?$r=substr($argv[1],-2,1)=="
"?strrev($argv[1]):$argv[1];
foreach(explode("
",$r)as$l){$s=strlen($l);$x[$s]=++$i;$m=$i==$s?'T':'M';}$z=count($x);echo$i*$z>2?$z==1&&key($x)==$i?'S':($z==1&&$i>2?'R':$m):M;

Original 181 bytes:

<?$r=substr($argv[1],-2,1)=="
"?strrev($argv[1]):$argv[1];
foreach(explode("
",$r)as$l){$s=strlen($l);$x[$s]=++$i;$m=$i==$s?T:M;}$z=count($x);echo $z==1&&key($x)==$i?S:($z==1?R:$m);

The upside down triangle adds an expensive 56 bytes to this!

Outputs are S,R,T,M

Saved a few bytes thanks to Dom Hastings (original was 190 bytes)

Try it online!

PHP, 191 bytes

Added the > 2 character restriction:

<?$a=$argv[1];$r=substr($a,-2,1)=="\n"?strrev($a):$a;foreach(explode("\n",$r)as$l){$s=strlen($l);$x[$s]=++$i;$m=$i==$s?T:M;}$z=count($x);echo$i*$z>2?$z==1&&key($x)==$i?S:($z==1&&$i>2?R:$m):M;

The upside down triangle adds an expensive 56 bytes to this!

Outputs are S,R,T,M

Saved a few bytes thanks to Dom Hastings

Try it online!

added 317 characters in body
Source Link
Dave
  • 161
  • 4
Loading
added 19 characters in body
Source Link
Dave
  • 161
  • 4
Loading
added 4 characters in body
Source Link
Dave
  • 161
  • 4
Loading
added 4 characters in body
Source Link
Dave
  • 161
  • 4
Loading
Source Link
Dave
  • 161
  • 4
Loading

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