# python trivial solution beats 97%

• ``````    s1 = a.split('+')
s2 = b.split('+')
ss1 = []
ss2 = []
ss1.append(s1[0])
ss2.append(s2[0])
if s1[1][0] == '-' and s2[1][0] == '-':
c = s1[1].split('-')
x1 = []
for i in range(len(c[1])-1):
x1.append(c[1][i])
y1 = ''.join(x1)
ss1.append(y1)
d = s2[1].split('-')
x2 = []
for j in range(len(d[1])-1):
x2.append(d[1][j])
y2 = ''.join(x2)
ss2.append(y2)
real = int(ss1[0])*int(ss2[0])-int(ss1[1])*int(ss2[1])
imag = -int(ss1[0])*int(ss2[1])-int(ss1[1])*int(ss2[0])
i1 = []
i1.append(str(imag))
i1.append(str('i'))
j1 = ''.join(i1)
r1 = []
r1.append(str(real))
r1.append(j1)
g1 = '+'.join(r1)

if s1[1][0] == '-' and s2[1][0] != '-':
c = s1[1].split('-')
x1 = []
for i in range(len(c[1])-1):
x1.append(c[1][i])
y1 = ''.join(x1)
ss1.append(y1)
x2 = []
for j in range(len(s2[1])-1):
x2.append(s2[1][j])
y2 = ''.join(x2)
ss2.append(y2)
real = int(ss1[0])*int(ss2[0])+int(ss1[1])*int(ss2[1])
imag = int(ss1[0])*int(ss2[1])-int(ss1[1])*int(ss2[0])
i1 = []
i1.append(str(imag))
i1.append(str('i'))
j1 = ''.join(i1)
r1 = []
r1.append(str(real))
r1.append(j1)
g1 = '+'.join(r1)

if s1[1][0] != '-' and s2[1][0] == '-':
x1 = []
for i in range(len(s1[1])-1):
x1.append(s1[1][i])
y1 = ''.join(x1)
ss1.append(y1)
d = s2[1].split('-')
x2 = []
for j in range(len(d[1])-1):
x2.append(d[1][j])
y2 = ''.join(x2)
ss2.append(y2)
real = int(ss1[0])*int(ss2[0])+int(ss1[1])*int(ss2[1])
imag = -int(ss1[0])*int(ss2[1])+int(ss1[1])*int(ss2[0])
i1 = []
i1.append(str(imag))
i1.append(str('i'))
j1 = ''.join(i1)
r1 = []
r1.append(str(real))
r1.append(j1)
g1 = '+'.join(r1)

if s1[1][0] != '-' and s2[1][0] != '-':
x1 = []
for i in range(len(s1[1])-1):
x1.append(s1[1][i])
y1 = ''.join(x1)
ss1.append(y1)
x2 = []
for j in range(len(s2[1])-1):
x2.append(s2[1][j])
y2 = ''.join(x2)
ss2.append(y2)
real = int(ss1[0])*int(ss2[0])-int(ss1[1])*int(ss2[1])
imag = int(ss1[0])*int(ss2[1])+int(ss1[1])*int(ss2[0])
i1 = []
i1.append(str(imag))
i1.append(str('i'))
j1 = ''.join(i1)
r1 = []
r1.append(str(real))
r1.append(j1)
g1 = '+'.join(r1)

return g1
``````

'''

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.