A symmetric polynomial is a polynomial which is unchanged under permutation of its variables.
In other words, a polynomial
f(x,y) is symmetric if and only if
f(x,y) = f(y,x); a polynomial
g(x,y,z) is symmetric iff
g(x,y,z) = g(x,z,y) = g(y,x,z) = etc.
x^3+x^2y+xy^2+y^3 are symmetric polynomials, where
x^2+y are not.
You will be given a polynomial, and your program should output truthy/falsy values, depending on if the given polynomial is a symmetric polynomial.
The input format is allowed in two ways. A string, and an array, like
["x^2","2xy","y^2"], where the polynomial is the sum of each elements.
x^2+2xy+y^2 => true xy => true xy+yz+xz-3xyz => true (x+y)(x-y) => false 2x+y => false x^2+y => false x+2y+3 => false
The operation has orders, just like in normal math. the order is like this:
() => ^ => * => +-
code-golf rules apply.
All the characters in the alphabet (
a~z) are accepted as variables, everything else are numbers.
The given polynomial will have 2 or more variables.
Multiplication does not require the * operator, You only need to detect juxtaposition. (detecting by juxtaposition is not neccessary, use the better option)