Skip to main content
-1 byte, better golfing thx to Night2
Source Link
640KB
  • 11.9k
  • 2
  • 35
  • 57

PHP, 7676 75 bytes

while(($x=strspn($argn,$argn[$n+=$x],$n))>1&&!(($m=max($m,$x))%$x)%$x<1);echo!$x;

Try it online!Try it online!

First attempt, a somewhat naïve iterative approach.

Ungolfed:

// get the length of the next span of the same char
while( $s = strspn( $argn, $argn[ $n ], $n ) ) {

    // if span is less than 2 chars long, input is not n-speak
    if ( $s < 2 ) {
        break;
    }

    // k is GCD
    $k = max( $k, $s );

    // if span length does not divide evenly into GCD, input is not n-speak
    if( ( $k % $s ) != 0 ) {
        break;
    }

    // increment current input string index
    $n += $s;

}

-1 byte, thx to @Night2!

PHP, 76 bytes

while(($x=strspn($argn,$argn[$n+=$x],$n))>1&&!(($m=max($m,$x))%$x));echo!$x;

Try it online!

First attempt, a somewhat naïve iterative approach.

Ungolfed:

// get the length of the next span of the same char
while( $s = strspn( $argn, $argn[ $n ], $n ) ) {

    // if span is less than 2 chars long, input is not n-speak
    if ( $s < 2 ) {
        break;
    }

    // k is GCD
    $k = max( $k, $s );

    // if span length does not divide evenly into GCD, input is not n-speak
    if( ( $k % $s ) != 0 ) {
        break;
    }

    // increment current input string index
    $n += $s;

}

PHP, 76 75 bytes

while(($x=strspn($argn,$argn[$n+=$x],$n))>1&&($m=max($m,$x))%$x<1);echo!$x;

Try it online!

First attempt, a somewhat naïve iterative approach.

Ungolfed:

// get the length of the next span of the same char
while( $s = strspn( $argn, $argn[ $n ], $n ) ) {

    // if span is less than 2 chars long, input is not n-speak
    if ( $s < 2 ) {
        break;
    }

    // k is GCD
    $k = max( $k, $s );

    // if span length does not divide evenly into GCD, input is not n-speak
    if( ( $k % $s ) != 0 ) {
        break;
    }

    // increment current input string index
    $n += $s;

}

-1 byte, thx to @Night2!

add ungolfed version
Source Link
640KB
  • 11.9k
  • 2
  • 35
  • 57

PHP, 76 bytes

while(($x=strspn($argn,$argn[$n+=$x],$n))>1&&!(($m=max($m,$x))%$x));echo!$x;

Try it online!

First attempt, a somewhat naïve iterative approach. Definitely one of those challenges that seemed easier before I started!

Ungolfed:

// get the length of the next span of the same char
while( $s = strspn( $argn, $argn[ $n ], $n ) ) {

    // if span is less than 2 chars long, input is not n-speak
    if ( $s < 2 ) {
        break;
    }

    // k is GCD
    $k = max( $k, $s );

    // if span length does not divide evenly into GCD, input is not n-speak
    if( ( $k % $s ) != 0 ) {
        break;
    }

    // increment current input string index
    $n += $s;

}

PHP, 76 bytes

while(($x=strspn($argn,$argn[$n+=$x],$n))>1&&!(($m=max($m,$x))%$x));echo!$x;

Try it online!

First attempt. Definitely one of those challenges that seemed easier before I started!

PHP, 76 bytes

while(($x=strspn($argn,$argn[$n+=$x],$n))>1&&!(($m=max($m,$x))%$x));echo!$x;

Try it online!

First attempt, a somewhat naïve iterative approach.

Ungolfed:

// get the length of the next span of the same char
while( $s = strspn( $argn, $argn[ $n ], $n ) ) {

    // if span is less than 2 chars long, input is not n-speak
    if ( $s < 2 ) {
        break;
    }

    // k is GCD
    $k = max( $k, $s );

    // if span length does not divide evenly into GCD, input is not n-speak
    if( ( $k % $s ) != 0 ) {
        break;
    }

    // increment current input string index
    $n += $s;

}
deleted 8 characters in body
Source Link
640KB
  • 11.9k
  • 2
  • 35
  • 57

PHP, 8476 bytes

forwhile($n=0;($x=strspn($argn,$argn[$n+=$x],$n))&&$x>1&&>1&&!(($m=max($m,$x))%$x););echo!$x;

Try it online!Try it online!

First attempt. Definitely one of those challenges that seemed easier before I started!

PHP, 84 bytes

for($n=0;($x=strspn($argn,$argn[$n+=$x],$n))&&$x>1&&!(($m=max($m,$x))%$x););echo!$x;

Try it online!

First attempt. Definitely one of those challenges that seemed easier before I started!

PHP, 76 bytes

while(($x=strspn($argn,$argn[$n+=$x],$n))>1&&!(($m=max($m,$x))%$x));echo!$x;

Try it online!

First attempt. Definitely one of those challenges that seemed easier before I started!

Source Link
640KB
  • 11.9k
  • 2
  • 35
  • 57
Loading