In mathematics, a [Diophantine equation](https://en.wikipedia.org/wiki/Diophantine_equation) is a polynomial equation, usually with two or more unknowns, such that only the integer solutions are sought or studied.

In this kata we want to find all integers `x, y` (`x >= 0, y >= 0`) solutions of a diophantine equation of the form:
#### x^(2) - 4 \* y^(2) = n

(where the unknowns are `x` and `y`, and `n` is a given positive number)
in decreasing order of the positive xi. 

If there is no solution return `[]` or `"[]" or ""`. (See "RUN SAMPLE TESTS" for examples of returns).


## Examples:

```
solEquaStr(90005) --> "[[45003, 22501], [9003, 4499], [981, 467], [309, 37]]"
solEquaStr(90002) --> "[]"
```

## Hint:

x^(2) - 4 \* y^(2) = (x - 2\*y) \* (x + 2\*y)

Source: codewars | Difficulty: EASY
Tags: Matrices

Fundamentals

Mathematics

Starter code: def sol_equa(n):
	

Solutions:
import math

def sol_equa(n):
	res = []
	for i in range(1, int(math.sqrt(n)) + 1):
		if n % i == 0:
			j = n // i
			if (i + j) % 2 == 0 and (j - i) % 4 == 0:
				x = (i + j) // 2
				y = (j - i) // 4
				res.append([x, y])
	return res


def sol_equa(n):
	return [[(n / i + i) / 2, (n / i - i) / 4] for i in range(1, int(n ** 0.5) + 1) if n % i == 0 and (n / i + i) % 2 == 0 and ((n / i - i) % 4 == 0)]


from math import sqrt

def factors(n):
	f = []
	for x in range(1, int(sqrt(n)) + 1):
		if n % x == 0:
			f.append([x, int(n / x)])
	return f

def sol_equa(n):
	ff = factors(n)
	res = []
	for f in ff:
		m = m = f[0] + f[1]
		n = f[1] - f[0]
		if m % 2 == 0 and n % 4 == 0:
			res.append([int(m / 2), int(n / 4)])
	return res


def sol_equa(n):
	res = []
	for a in range(1, int(n ** 0.5 + 1) + 1):
		if n % a == 0:
			b = n / a
			if (a + b) % 2 == 0 and (b - a) % 4 == 0:
				res.append([(a + b) / 2, (b - a) / 4])
	return res


def sol_equa(n):
	(solutions, i) = ([], 1)
	while i * i <= n:
		if n % i == 0:
			j = n // i
			if (i + j) % 2 == 0:
				x = (i + j) // 2
				(v, V) = (i - x, j - x)
				if v % 2 == 0 and v == V * -1:
					y = abs(v // 2)
					solutions.append([x, y])
		i += 1
	return solutions


import math

def sol_equa(n):
	result = []
	for i in range(1, int(math.ceil(math.sqrt(n))) + 1):
		if n % i == 0:
			A = i + n / i
			B = abs(i - n / i)
			if A % 2 == 0 and B % 4 == 0:
				result.append([A / 2, B / 4])
	return result


import math

def sol_equa(n):
	ls = []
	for i in range(1, int(math.sqrt(n)) + 1):
		if n % i == 0:
			ls.append(i)
	ans = []
	for root in ls:
		x = int((root + int(n / root)) / 2)
		y = int((max(root, int(n / root)) - x) / 2)
		if int(x + 2 * y) * (x - 2 * y) == n:
			ans.append([x, y])
	return ans


from math import sqrt

def sol_equa(n):
	m = [[y, n / y] for y in [x for x in range(1, int(sqrt(n)) + 1) if n % x == 0]]
	return sorted([[(r[0] + r[1]) / 2, (r[1] - r[0]) / 4] for r in [z for z in m if (z[0] + z[1]) % 2 == 0 and (z[1] - z[0]) % 4 == 0]], reverse=True)


def sol_equa(n):
	f = [[i, n // i] for i in range(1, int(n ** 0.5) + 1) if not n % i]
	return [[(a + b) // 2, (b - a) // 4] for (a, b) in f if ((a + b) // 2) ** 2 - 4 * ((b - a) // 4) ** 2 == n]


def sol_equa(n):
	res = []
	if n <= 0:
		return res
	for i in range(1, int(pow(n, 1 / 2) + 1)):
		if int(n % i) == 0 and int(n - i * i) % (4 * i) == 0:
			res.append([int((i + n / i) / 2), int((n / i - i) / 4)])
	return res