Problem Statement
Let's say numbers A and B are symmetrical if A can be obtained from B by reading B backwards. For example, "123" and "321" are symmetrical, but "112" and "221" are not. A number is self-symmetrical if it is symmetrical to itself.
To check whether number C is antisymmetrical, you need to compute its symmetrical number D. If every digit in C is different from the digit in D at the corresponding position, then numbers C and D are antisymmetrical.
Given an int X, return "ANTI" if it is antisymmetrical, "SELF" if it is self-symmertical, or "NONE" otherwise (all quotes for clarity).
Definition
- Class:
- AntisymmetricalNumbers
- Method:
- test
- Parameters:
- int
- Returns:
- String
- Method signature:
- String test(int X)
- (be sure your method is public)
Constraints
- X will be between 1 and 9999, inclusive.
- X will not be divisible by 10.
Examples
14
Returns: "ANTI"
"14" backwards is "41". The first digits of these two numbers ('1' and '4', respectively) are different, and the second digits ('4' and '1', respectively) are also different, so the number is antisymmetrical.123
Returns: "NONE"
"123" backwards is "321". The second digit in both numbers is '2', so the number is not antisymmetrical.131
Returns: "SELF"
"131" backwards is "131", which is the same number. This means it's self-symmetrical.1
Returns: "SELF"
1212
Returns: "ANTI"
9809
Returns: "NONE"