Given a rational number n

``` n >= 0, with denominator strictly positive```  

- as a string (example: "2/3" in Ruby, Python, Clojure, JS, CS, Go) 
- or as two strings (example: "2" "3" in Haskell, Java, CSharp, C++, Swift) 
- or as a rational or decimal number (example: 3/4, 0.67 in R) 
- or two integers (Fortran)

decompose 
this number as a sum of rationals with numerators equal to one and without repetitions
(2/3 = 1/2 + 1/6 is correct but not 2/3 = 1/3 + 1/3, 1/3 is repeated).
    
The algorithm must be "greedy", so at each stage the new rational obtained in the decomposition must have a denominator as small as possible. 
In this manner the sum of a few fractions in the decomposition gives a rather good approximation of the rational to decompose.
    
2/3 = 1/3 + 1/3 doesn't fit because of the repetition but also because the first 1/3 has a denominator bigger than the one in 1/2 
in the decomposition 2/3 = 1/2 + 1/6.
    
### Example: 
(You can see other examples in "Sample Tests:")
```
decompose("21/23") or "21" "23" or 21/23 should return 

["1/2", "1/3", "1/13", "1/359", "1/644046"] in Ruby, Python, Clojure, JS, CS, Haskell, Go

"[1/2, 1/3, 1/13, 1/359, 1/644046]" in Java, CSharp, C++

"1/2,1/3,1/13,1/359,1/644046" in C, Swift, R
```  

### Notes
1) The decomposition of 21/23 as
```
21/23 = 1/2 + 1/3 + 1/13 + 1/598 + 1/897
```
is exact but don't fulfill our requirement because 598 is bigger than 359.
Same for 
```
21/23 = 1/2 + 1/3 + 1/23 + 1/46 + 1/69 (23 is bigger than 13)
or 
21/23 = 1/2 + 1/3 + 1/15 + 1/110 + 1/253 (15 is bigger than 13).
```
    
2) The rational given to decompose could be greater than one or equal to one, in which case the first "fraction" will be an integer 
(with an implicit denominator of 1). 

3) If the numerator parses to zero the function "decompose" returns [] (or "".

4) The number could also be a decimal which can be expressed as a rational. 

examples:

`0.6` in Ruby, Python, Clojure,JS, CS, Julia, Go
  
`"66" "100"` in Haskell, Java, CSharp, C++, C, Swift, Scala, Kotlin

`0.67` in R.

**Ref:**
http://en.wikipedia.org/wiki/Egyptian_fraction

Difficulty: EASY
Tags: Mathematics

Starter code:
def decompose(n):
	

Solutions:
from math import ceil
from fractions import Fraction as F

def decompose(n):
	f = F(n)
	ff = int(f)
	result = [str(ff)] if ff else []
	f -= ff
	while f > 0:
		x = F(1, int(ceil(f ** (-1))))
		f -= x
		result.append(str(x))
	return result


from fractions import Fraction
from math import ceil

def decompose(n):
	try:
		n = Fraction(n)
	except ValueError:
		return []
	try:
		e = int(n)
	except ValueError:
		return []
	if n == 0:
		return []
	if n == e:
		return [str(n)]
	n -= e
	if e != 0:
		l = [str(e)]
	else:
		l = []
	while n.numerator > 1:
		e = Fraction(1, int(ceil(1 / n)))
		l.append(str(e.numerator) + '/' + str(e.denominator))
		n -= e
	l.append(str(n.numerator) + '/' + str(n.denominator))
	return l


from fractions import Fraction
from math import ceil

def decompose(n):
	f = Fraction(n)
	result = []
	if f > 1:
		int_part = int(f)
		result = [str(int_part)]
		f -= int_part
	while f:
		x = Fraction(1, ceil(1 / f))
		result.append(str(x))
		f -= x
	return result


from fractions import Fraction as fr
from math import ceil

def decompose(s):
	s = str(fr(s)).split('/')
	if len(s) == 1:
		return [s, []][s[0] == '0']
	li = [[1, ceil(eval('int(s[1]) / int(s[0])'))]]
	while 1:
		(n, d) = li[-1]
		s = str(fr(int(s[0]), int(s[1])) - fr(n, d)).split('/')
		if len(s) == 1:
			break
		li.append([1, ceil(eval('int(s[1]) / int(s[0])'))])
	return [str(fr(f'{i}/{j}')) for (i, j) in li]


def decompose(n):
	if '/' in n:
		strs = n.split('/')
		a = int(strs[0])
		b = int(strs[1])
	elif '.' in n:
		strs = n.split('.')
		b = 10 ** len(strs[1])
		a = int(strs[1]) + b * int(strs[0])
	else:
		a = int(n)
		b = 1
	output = []
	while a >= b:
		i = a // b
		a = a - b * i
		output.append(str(i))
	while a > 0:
		i = b // a + 1 if b % a else b // a
		a = a * i - b
		b = b * i
		output.append('1/' + str(i))
	return output


from fractions import Fraction

def decompose(n):
	answer = []
	current_number = Fraction(n)
	if current_number > 1:
		answer.append(str(current_number // 1))
		current_number = Fraction(current_number - current_number // 1)
	if current_number == 0:
		return answer
	x = 2
	while True:
		if Fraction(1, x) < current_number:
			answer.append(str(Fraction(1, x)))
			current_number = Fraction(current_number - Fraction(1, x))
		if current_number.numerator == 1:
			answer.append(str(current_number))
			break
		else:
			x = current_number.denominator // current_number.numerator + 1
	return answer


from fractions import Fraction
import math

def decompose(n):
	if n == '0':
		return []
	refFrac = Fraction(n)
	if refFrac.numerator == refFrac.denominator:
		return ['1']
	elif refFrac.denominator == 1:
		return [str(refFrac.numerator)]
	final_tab = []
	while refFrac.numerator != 0:
		denom = math.ceil(refFrac.denominator / refFrac.numerator)
		next = Fraction(1, denom)
		final_tab.append(next)
		refFrac -= next
	return [str(frac) for frac in final_tab]


def decompose(n):
	from fractions import Fraction
	f = Fraction(n)
	ret = []
	if 0 == f:
		return ret
	while not (f.numerator == 1 or f.denominator == 1):
		x = int(1 / f) + 1
		ff = Fraction(1, x)
		ret.append(str(ff))
		f -= ff
	else:
		ret.append(str(f))
	return ret


from fractions import Fraction
import sys
from math import floor, ceil

class EgyptianFraction(Fraction):

	def decompose(self, rst=None):
		if rst is None:
			rst = []
		if self == 0:
			return rst
		elif self.numerator == 1 or self.denominator == 1:
			rst.append(Fraction(self))
			return rst
		if self > 1:
			frac = Fraction(floor(self))
		else:
			frac = Fraction(1, ceil(1 / self))
		rst.append(frac)
		return EgyptianFraction(self - frac).decompose(rst)

def decompose(n):
	rst = EgyptianFraction(n).decompose()
	return [str(i) for i in rst]


from fractions import Fraction
from math import ceil

def decompose(n):
	n = Fraction(n)
	(lst, n) = ([int(n)], n - int(n))
	while n > 0:
		next_denom = int(ceil(1 / n))
		lst.append(next_denom)
		n -= Fraction(1, next_denom)
	return ([] if lst[0] == 0 else [str(lst[0])]) + ['1/{}'.format(d) for d in lst[1:]]