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})}
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