Created
August 24, 2021 07:40
-
-
Save goish135/a0808e664ebab8965e5d7d7dc273218e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def complexNumberMultiply(self, num1: str, num2: str) -> str: | |
#print(num1.split("+")) | |
#print(complex(int(num1[0]),int(num1[0].split("i")[0]))) | |
a = complex(int(num1.split("+")[0]),int(num1.split("+")[1].split("i")[0])) | |
b = complex(int(num2.split("+")[0]),int(num2.split("+")[1].split("i")[0])) | |
print(a) | |
print(b) | |
#print(a*b) | |
c = a*b | |
#print(c.real) | |
#print(c.imag) | |
ans = str(int(c.real))+"+"+str(int(c.imag))+"i" | |
#print(ans) | |
return ans | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment