Try it online! - Perl
Try it online! - PCRE2
Try it online!Try it online! - Boost
Try it online! - Python
Try it online! - Ruby
Try it online! - .NET
^
(-)? # \1 = negative sign if it is present; unset otherwise
( # loop the following:
(x*)\3\3(?=\3$) # assert tail is divisible by 4; tail = tail / 4
)* # iterate as many times as possible (minimum 0)
x # tail = tail - 1
(?(1)x) # if \1 is set, then tail = tail - 1, else do nothing
$ # assert tail == 0
Regex (ECMAScript or better), 26 bytes
^((.*)\2\2(?=\2$))*(x|oo)$
Try it online! - ECMAScript
Try it online! - Perl
Try it online! - Java
Try it online! - Boost
Try it online! - Python
Try it online! - Ruby
Try it online! - PCRE2
Try it online! - .NET
Takes its input in bijective signed unary. A nonnegative number is a string of x
characters, and a nonpositive number is a string of o
characters. The the length of the string is the absolute value of the number.
^ # tail = N = input number
( # Loop the following:
(.*)\2\2(?=\2$) # Assert tail is divisible by 4; tail = tail / 4;
# use "." so that either "x" or "o" can be matched, as
# long as all characters are identical.
)* # Iterate as many times as possible (minimum 0).
(x|oo)$ # Assert tail == 1 or tail == -2