Really Complex Sum
Description:
Your program will receive an array of complex numbers represented as strings. Your task is to write the complexSum
function which have to return the sum as a string.
Complex numbers can be written in the form of a+bi
, such as 2-3i
where 2
is the real part, 3
is the imaginary part, and i
is the "imaginary unit".
When you add two complex numbers, the real and the imaginary part needs to be added separately,so for example 2+3i + 5-i = (2+5)+(3i-i) = 7+2i
Both the complex and the imaginary part can be 0, so 123
, -2i
or i
are also complex numbers.
Complex numbers must be returned in their shortest form, so e.g. 0+1*i
should be just i
, and 10+0i
should be 10
. This is also how you will get them!
For simplicity, the coefficients will always be integers. If the array is empty, return 0
.
Have fun! :)
Similar Kata:
Stats:
Created | Mar 1, 2018 |
Published | Mar 1, 2018 |
Warriors Trained | 893 |
Total Skips | 17 |
Total Code Submissions | 6460 |
Total Times Completed | 242 |
JavaScript Completions | 93 |
Python Completions | 160 |
Total Stars | 26 |
% of votes with a positive feedback rating | 86% of 91 |
Total "Very Satisfied" Votes | 72 |
Total "Somewhat Satisfied" Votes | 13 |
Total "Not Satisfied" Votes | 6 |
Total Rank Assessments | 5 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |