6 kyu

Really Complex Sum

93 of 242AndrasG

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! :)

Regular Expressions
Fundamentals

More By Author:

Check out these other kata created by AndrasG

Stats:

CreatedMar 1, 2018
PublishedMar 1, 2018
Warriors Trained893
Total Skips17
Total Code Submissions6460
Total Times Completed242
JavaScript Completions93
Python Completions160
Total Stars26
% of votes with a positive feedback rating86% of 91
Total "Very Satisfied" Votes72
Total "Somewhat Satisfied" Votes13
Total "Not Satisfied" Votes6
Total Rank Assessments5
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • AndrasG Avatar
  • JohanWiltink Avatar
  • Blind4Basics Avatar
  • fr0ggy Avatar
  • mauro-1 Avatar
Ad