A higher resolution is required to access the IDE
- 150
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
The quaternions belong to a number system that extends the complex numbers. A quaternion is defined by the sum of scalar multiples of the constantsMore information is available at http://mathworld.wolfram.com/Quaternion.html
Consider the following properties:
These properties also imply that:
The order of multiplication is important.
Your program must output the result of the product of a number of bracketed simplified quaternions.
Pay attention to the formatting
The coefficient is appended to the left of the constant.
If a coefficient is
If a coefficient or scalar term is
The terms must be displayed in order: a
Example Multiplication
(2i+2j)(j+1) = (2ij+2i+2j² +2j) = (2k+2i-2+2j) = (2i+2j+2k-2)
Input
Line 1:The expression expr to evaluate. This will always be the product of simplified bracketed expressions.
Output
A single line containing the simplified result of the product expression. No brackets are required.
Constraints
All coefficients in any part of evaluation will be less than 10^9
The input contains no more than 10 simplified bracketed expressions
The input contains no more than 10 simplified bracketed expressions
Example
Input
(i+j)(k)
Output
i-j
A higher resolution is required to access the IDE