Skip to main content
-5 bytes thanks to mazzy
Source Link
AdmBorkBork
  • 43.5k
  • 5
  • 103
  • 284

PowerShell, 6464 59 bytes

filter f($n){$a,$b,$r=$n;if($r){$a$r=$n;$a-eq$b-andand$(if($r){f $r)}else{$a-eq$b1})}

Try it online!Try it online!

Recursive function, no regex. Takes input as a char-array (see TIO link). Peels off the first two elements into $a and $b, stores the remaining into $r. If we still have elements remaining, recurse along with $a -eq $b. Otherwise just check whether $a -eq $b. Output is implicit.

(There's got to be a way to de-duplicate the $a-eq$b, but I can't seem5 bytes thanks to find it)mazzy

PowerShell, 64 bytes

filter f($n){$a,$b,$r=$n;if($r){$a-eq$b-and(f $r)}else{$a-eq$b}}

Try it online!

Recursive function, no regex. Takes input as a char-array (see TIO link). Peels off the first two elements into $a and $b, stores the remaining into $r. If we still have elements remaining, recurse along with $a -eq $b. Otherwise just check whether $a -eq $b. Output is implicit.

(There's got to be a way to de-duplicate the $a-eq$b, but I can't seem to find it)

PowerShell, 64 59 bytes

filter f($n){$a,$b,$r=$n;$a-eq$b-and$(if($r){f $r}else{1})}

Try it online!

Recursive function, no regex. Takes input as a char-array (see TIO link). Peels off the first two elements into $a and $b, stores the remaining into $r. If we still have elements remaining, recurse along with $a -eq $b. Otherwise just check whether $a -eq $b. Output is implicit.

-5 bytes thanks to mazzy

Source Link
AdmBorkBork
  • 43.5k
  • 5
  • 103
  • 284

PowerShell, 64 bytes

filter f($n){$a,$b,$r=$n;if($r){$a-eq$b-and(f $r)}else{$a-eq$b}}

Try it online!

Recursive function, no regex. Takes input as a char-array (see TIO link). Peels off the first two elements into $a and $b, stores the remaining into $r. If we still have elements remaining, recurse along with $a -eq $b. Otherwise just check whether $a -eq $b. Output is implicit.

(There's got to be a way to de-duplicate the $a-eq$b, but I can't seem to find it)