For a given two numbers your mission is to derive a function that evaluates whether two given numbers are **abundant**, **deficient** or **perfect** and whether together they are **amicable**.



### Abundant Numbers
An abundant number or excessive number is a number for which the sum of its proper divisors is greater than the number itself.

The integer 12 is the first abundant number. Its proper divisors are 1, 2, 3, 4 and 6 for a total of 16 (> 12).

### Deficient Numbers
A deficient number is a number for which the sum of its proper divisors is less than the number itself.

The first few deficient numbers are: 1, 2, 3, 4, 5, 7, 8, 9.

### Perfect Numbers
A perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself. 

The first perfect number is 6, because 1, 2, and 3 are its proper positive divisors, and 1 + 2 + 3 = 6.

### Amicable Numbers
Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the other number. (A proper divisor of a number is a positive factor of that number other than the number itself. For example, the proper divisors of 6 are 1, 2, and 3.)

For example, the smallest pair of amicable numbers is (220, 284); for the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, of which the sum is 284; and the proper divisors of 284 are 1, 2, 4, 71 and 142, of which the sum is 220.

### The Function

For a given two numbers, derive function `deficientlyAbundantAmicableNumbers(num1, num2)` which returns a string with first and second word either abundant or deficient depending on whether `num1` or `num2` are abundant, deficient or perfect. The string should finish with either amicable or not amicable depending on the relationship between `num1` and `num2`.

e.g. `deficientlyAbundantAmicableNumbers(220, 284)` returns `"abundant deficient amicable"` as 220 is an abundant number, 284 is a deficient number and amicable because 220 and 284 are an amicable number pair. 





See Part 1 - [Excessively Abundant Numbers](http://www.codewars.com/kata/56a75b91688b49ad94000015)

See Part 2 - [The Most Amicable of Numbers](http://www.codewars.com/kata/56b5ebaa26fd54188b000018)

Difficulty: EASY
Tags: Fundamentals

Mathematics

Starter code:
def deficiently_abundant_amicable_numbers(n1, n2):
	

Solutions:
def deficiently_abundant_amicable_numbers(a, b):
	(c, d) = list(map(sumOfDivs, (a, b)))
	return f"{kind(a, c)} {kind(b, d)} {'not ' * (a != d or b != c or a == b)}amicable"

def kind(n, sD):
	return 'abundant' if sD > n else 'perfect' if sD == n else 'deficient'

def sumOfDivs(n):
	return sum((d for d in range(1, int(n / 2 + 1)) if not n % d))


def deficiently_abundant_amicable_numbers(n1, n2):
	(d1, d2) = (sum((d for d in range(1, n // 2 + 1) if n % d == 0)) for n in (n1, n2))
	is_amicable = 'not ' if n1 == n2 or (n1, n2) != (d2, d1) else ''
	return f'{perfection(n1, d1)} {perfection(n2, d2)} {is_amicable}amicable'

def perfection(n, d):
	return 'deficient' if d < n else 'abundant' if n < d else 'perfect'


def pdsum(n):
	xs = {1}
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			xs.add(i)
			xs.add(n // i)
	return sum(xs)

def describe(s, n):
	if s < n:
		return 'deficient'
	elif s > n:
		return 'abundant'
	else:
		return 'perfect'

def deficiently_abundant_amicable_numbers(n1, n2):
	(s1, s2) = (pdsum(n) for n in [n1, n2])
	return '{} {} {}'.format(describe(s1, n1), describe(s2, n2), 'amicable' if s1 == n2 and s2 == n1 and (n1 != n2) else 'not amicable')


def deficiently_abundant_amicable_numbers(n1, n2):
	(d1, d2) = (sum((d for d in range(1, n // 2 + 1) if n % d == 0)) for n in (n1, n2))
	perf = ' '.join(('deficient' if d < n else 'abundant' if n < d else 'perfect' for (n, d) in ((n1, d1), (n2, d2))))
	is_amic = '' if n1 != n2 and (n1, n2) == (d2, d1) else 'not '
	return f'{perf} {is_amic}amicable'


def sum_of_divisors(number):
	divisors = [1]
	i = 2
	while i < number // i:
		if not number % i:
			divisors.append(i)
			divisors.append(number // i)
		i += 1
	if i ** 2 == number:
		divisors.append(i)
	return sum(divisors)

def is_perfect(number):
	return number == sum_of_divisors(number)

def is_amicable(number_1, number_2):
	return number_2 == sum_of_divisors(number_1)

def deficiently_abundant_amicable_numbers(n1, n2):
	perfect_1 = 'perfect' if is_perfect(n1) else False
	if not perfect_1:
		perfect_1 = 'abundant' if n1 < sum_of_divisors(n1) else 'deficient'
	perfect_2 = 'perfect' if is_perfect(n2) else False
	if not perfect_2:
		perfect_2 = 'abundant' if n2 < sum_of_divisors(n2) else 'deficient'
	amicable = 'amicable' if is_amicable(n1, n2) and (not (is_perfect(n1) and is_perfect(n2))) else 'not amicable'
	return perfect_1 + ' ' + perfect_2 + ' ' + amicable


def deficiently_abundant_amicable_numbers(n1, n2):

	def check(n):
		temp = set([1])
		for j in range(2, int(n ** 0.5) + 1):
			if n % j == 0:
				temp.add(j)
				temp.add(n // j)
		x = sum(temp)
		return x
	lst = ['abundant', 'perfect', 'deficient']
	(a1, a2) = (check(n1), check(n2))
	ans1 = lst[0] if a1 > n1 else lst[1] if a1 == n1 else lst[2]
	ans2 = lst[0] if a2 > n2 else lst[1] if a2 == n2 else lst[2]
	return '{} {} {}'.format(ans1, ans2, 'amicable' if a1 == n2 and a2 == n1 and (n1 != n2) else 'not amicable')


def divs(n):
	s = 1
	for i in range(2, int(n ** 0.5) + 1):
		if not n % i:
			s += i
			s += n // i
	return s

def deficiently_abundant_amicable_numbers(n1, n2):
	(d1, d2) = map(divs, (n1, n2))
	f = lambda x, y: 'perfect' if x == y else 'abundant' if x > y else 'deficient'
	return f"{f(d1, n1)} {f(d2, n2)} {('amicable' if d1 == n2 and d2 == n1 and (n1 != n2) else 'not amicable')}"