In this Kata you are expected to find the coefficients of quadratic equation of the given two roots (`x1` and `x2`).

Equation will be the form of ```ax^2 + bx + c = 0```

Return type is a Vector (tuple in Rust, Array in Ruby) containing coefficients of the equations in the order `(a, b, c)`.

Since there are infinitely many solutions to this problem, we fix `a = 1`.

Remember, the roots can be written like `(x-x1) * (x-x2) = 0`

### Example 

    quadratic(1,2) = (1, -3, 2)

This means `(x-1) * (x-2) = 0`; when we do the multiplication this becomes `x^2 - 3x + 2 = 0`

### Example 2

    quadratic(0,1) = (1, -1, 0)

This means `(x-0) * (x-1) = 0`; when we do the multiplication this becomes `x^2 - x + 0 = 0`

### Notes

* Inputs will be integers.
* When `x1 == x2`, this means the root has the multiplicity of two

Difficulty: EASY
Tags: Matrices

Fundamentals

Mathematics

Starter code:
def quadratic(x1, x2):
	

Solutions:
def quadratic(x1, x2):
	return (1, -x1 - x2, x1 * x2)


import numpy as np

def quadratic(*args):
	return tuple(np.poly(args))


quadratic = lambda x, y: (1, -x - y, x * y)


def quadratic(x1, x2):
	a = 1
	b = -(x1 + x2)
	c = x1 * x2
	return (a, b, c)


def quadratic(a, b):
	return (1, 0 - a - b, a * b)


def quadratic(x1, x2):
	coef = [1]
	coef.append(-x1 - x2)
	coef.append(x1 * x2)
	return tuple(coef)


def quadratic(x1, x2):
	if x1 != x2:
		c = (x1 * x1 * x2 - x2 * x2 * x1) / (x1 - x2)
		b = (-c - x1 * x1) / x1 if x1 else (-c - x2 * x2) / x2
		return (1, b, c)
	else:
		return (1, -2 * x1, x1 * x1)


def quadratic(x1, x2):
	if x1 or x2 >= 0:
		sum = x1 + x2
		mult = x1 * x2
		return (1, -sum, mult)
	if x1 or x2 <= 0:
		sum1 = x1 + x2
		mult1 = x1 * x2
		return (1, sum1, mult1)


quadratic = lambda r1, r2: (1, -(r1 + r2), r1 * r2)


def quadratic(x1, x2):
	f = -x2
	t = -x1
	z = f + t
	e = -x1 * -x2
	return (1, z, e)


def quadratic(x1, x2):
	output = 1
	output1 = -x1 - x2
	output2 = x1 * x2
	return (output, output1, output2)


def quadratic(x1, x2):
	b = -x1 - x2
	c = x1 * x2
	array = (1, b, c)
	return array


import numpy as np

def quadratic(x1, x2):
	b = -1 * (x1 + x2)
	c = x1 * x2
	return (1, b, c)
	pass


def quadratic(x1, x2):
	a = []
	a.append(1)
	a.append(-(x1 + x2))
	a.append(x1 * x2)
	a = tuple(a)
	return a


def quadratic(x1, x2):
	if x1 + x2 > 0:
		return (1, -x1 - x2, x1 * x2)
	else:
		return (1, -x1 - x2, x1 * x2)


def quadratic(x1, x2):
	print((x1, x2))
	a = 1
	if x2 - x1 != 0:
		b = (x1 ** 2 - x2 ** 2) / (x2 - x1)
		c = -x1 ** 2 - b * x1
	else:
		c = x1 ** 2
		b = -2 * x1
	return (a, b, c)


def quadratic(x1, x2):
	x = 1
	y = x1 + x2
	z = x1 * x2
	return (x, -y, z)


def quadratic(x1, x2):
	a = 1
	b = a * -x2 + a * -x1
	c = -x1 * -x2
	return (a, b, c)
print(quadratic(1, 2))


def quadratic(x1, x2):
	coff = [1]
	coff.append(-x2 - x1)
	coff.append(-x1 * -x2)
	return tuple(coff)


def quadratic(x1, x2):
	ans = []
	ans.append(1)
	ans.append(-(x1 + x2))
	ans.append(x1 * x2)
	return tuple(ans)


def quadratic(x1, x2):
	a = 1
	b = -x1 - x2
	c = (b ** 2 - (x1 - x2) ** 2) / 4
	return (a, b, c)


def quadratic(x1, x2):
	y = -(x1 + x2)
	t = (1, y, x1 * x2)
	return t


import math

def quadratic(x1, x2):
	a = 1
	b = -x1 - x2
	c = x1 * x2
	return (a, b, c)


def quadratic(x1, x2):
	co1 = 1
	co2 = -(x2 + x1)
	co3 = x1 * x2
	result = (co1, co2, co3)
	return result


def quadratic(x1, x2):
	return (1, -x1 - x2, x1 * x2)
x = quadratic(56, 99)
print(x)


def quadratic(x1, x2):
	a = 1
	if x1 < 0:
		c = x1 * x2
	else:
		c = x1 * x2
	if x1 > 0 or x2 > 0:
		b = -(x1 + x2)
	else:
		b = abs(x1 + x2)
	tuple = (a, b, c)
	return tuple


def quadratic(x1, x2):
	x = 1
	f = (x * x, x * -x2, -x1 * x, -x1 * -x2)
	return (f[0], f[1] + f[2], f[3])


def quadratic(x1, x2):
	x = 1
	formula = (x * x, x * -x2, -x1 * x, -x1 * -x2)
	return (formula[0], formula[1] + formula[2], formula[3])


def quadratic(x1, x2):
	int(x1)
	int(x2)
	thisdict = {'a': 1, 'b': -x1 + -x2, 'c': -x1 * -x2}
	return (thisdict.get('a'), thisdict.get('b'), thisdict.get('c'))


def quadratic(x1, x2):
	d = (x1 + x2) ** 2 - 4 * x1 * x2
	c = x1 * x2
	b = -1 * (x1 + x2)
	return (1, b, c)


def quadratic(x1, x2):
	p = -1 * (x1 + x2)
	q = x1 * x2
	b = p
	c = q
	a = 1
	return (a, b, c)


def quadratic(x1, x2):
	sum = x1 + x2
	sum = sum * -1
	mul = x1 * x2
	list = (1, sum, mul)
	return list


def quadratic(a, b):
	return tuple([1, -a + -b, -a * -b])


def quadratic(x1, x2):
	if x1 == x2:
		return (1, int(-2 * x1), int(x1 ** 2))
	else:
		b = (x1 ** 2 - x2 ** 2) / (x2 - x1)
		return (1, int(b), int(-1 * x1 ** 2 - b * x1))


def quadratic(m, n):
	return (1, -(m + n), m * n)


def quadratic(x1, x2):
	(a, b, c) = (0, -(x1 + x2), x1 * x2)
	if x1 * x2 != 0:
		a = c / (x1 * x2)
	elif x1 + x2 != 0:
		a = -b / (x1 + x2)
	return (a, b, c)


def quadratic(x1, x2):
	lst = list()
	a = 1
	lst.append(a)
	b = -(x1 + x2)
	lst.append(b)
	c = x1 * x2
	lst.append(c)
	tpl = tuple(lst)
	return tpl


def quadratic(x1, x2):
	lst = ()
	a = 1
	c = x1 * x2
	b = -x1 - x2
	lst = (a, b, c)
	return lst
pass


def quadratic(x1, x2):
	a = 1
	c = x1 * x2
	if x1 != x2:
		b = -(x1 + x2)
	if x1 == x2:
		b = -2 * x1
	return (a, b, c)


def quadratic(x1, x2):
	if isinstance(x1, int) and isinstance(x2, int):
		b = -(x1 + x2)
		c = x1 * x2
		return (1, b, c)
	else:
		return False
print(quadratic(1, 3))