Skip to content

Instantly share code, notes, and snippets.

@goish135
Created August 24, 2021 07:40
Show Gist options
  • Save goish135/a0808e664ebab8965e5d7d7dc273218e to your computer and use it in GitHub Desktop.
Save goish135/a0808e664ebab8965e5d7d7dc273218e to your computer and use it in GitHub Desktop.
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