Skip to content

Instantly share code, notes, and snippets.

@MinekPo1
Last active September 15, 2022 19:17
Show Gist options
  • Save MinekPo1/47eced044a365daf0933acffb4fa033a to your computer and use it in GitHub Desktop.
Save MinekPo1/47eced044a365daf0933acffb4fa033a to your computer and use it in GitHub Desktop.
I didn't feel like calculating my math homework by hand (I mean with a calculator but still) so I made python do it for me.
: -3,0,3,0,0,0,9
b: 1,-1
[-3.0, -3.0, 0.0, 0.0, 0.0, 0.0]
[9.0]
a = input("a: ")
a = list(map(lambda i: float(i),a.split(",")))
b = input("b: ")
b = list(map(lambda i: float(i),b.split(",")))
d_len = len(a) - len(b)
o = [0] * (d_len + 1)
for i in range(d_len+1):
m = a[i] / b[0]
for j,v in enumerate(b[1:]):
a[i+j+1] -= v * m
o[i] = m
a[i] -= m
print(o)
print(a[-(len(b)-1):])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment