## Problem

There are `n` apples that need to be divided into four piles. We need two mysterious number `x` and `y`. Let The number of first pile equals to `x+y`, the number of second pile equals to `x-y`, the number of third pile equals to `x*y`, the number of fourth pile equals to `x/y`. We need to calculate how many apples are there in each pile.

Of course, there won't be so many unknowns. We know the total number of apples(`n`) and the second mysterious number(`y`). 

For example: there are 48 apples need to divided into four piles. y=3. that is, 1st pile should be x+3, 2nd pile should be x-3, 3rd pile should be x*3, 4th pile should be x/3.
Do you know how much `x` is? `x` should be 9, because:
```
(9 + 3) + (9 - 3) + (9 * 3) + (9 / 3) = 12 + 6 + 27 + 3 = 48
```
So, 48 apples should be divided into `12, 6, 27, 3`.

## Task

Complete function `fourPiles()`/`four_piles()` that accepts two arguments `n` and `y`, return an array contains the number of for piles. Each element in the result array should be a positive integer. If can not divide, please return `[]`.

## Examples

```
fourPiles 48 3 -- [12,6,27,3]  
//The elements are arranged in sequence according to:
//   x+y,x-y,x*y,x/y

fourPiles 100 4 -- [20,12,64,4]  
-- Verify correctness:
-- x=16,y=4
(16+4) + (16-4) + (16*4) + (16/4) -- 100

-- Edge case:
fourPiles 25 4  -- []  -- [8,0,16,1] is not a correct answer

fourPiles 24 4  -- []  -- can not divide
```

Source: codewars | Difficulty: EASY
Tags: Game theory

Ad-hoc

Starter code: def four_piles(n,y):
	

Solutions:
def four_piles(n, y):
	(x, r) = divmod(n * y, (y + 1) ** 2)
	return [] if r or x == y else [x + y, x - y, x * y, x // y]


def four_piles(n, y):
	x = y * n / (y ** 2 + 2 * y + 1)
	return [x + y, x - y, x * y, x / y] if int(x) == x and x - y > 0 else []


def four_piles(n, y):
	x = y * n / (1 + 2 * y + y ** 2)
	ans = [x + y, x - y, x * y, x / y]
	return ans if all((not z % 1 and z for z in ans)) else []


def four_piles(n, y):
	x = round(n / (2 + y + 1 / y))
	ls = [x + y, x - y, x * y, x / y]
	return ls if x - y > 0 and x % y == 0 and (sum(ls) == n) else []


four_piles = lambda n, y: (lambda x, m: ((x > y) > x % y + m) * [x + y, x - y, x * y, x / y])(*divmod(n * y, y * y + 2 * y + 1))


def four_piles(n, y):
	candidates = ([x + y, x - y, x * y, x / y] for x in range(y + 1, int(n) - y + 1))
	return next((candidate for candidate in candidates if sum(candidate) == n), [])


four_piles = lambda n, y: (lambda r: r if all((e % 1 == 0 and e > 0 for e in r)) else [])((lambda x: [x + y, x - y, x * y, x / y])(n * y / (2 * y + y * y + 1)))


def four_piles(n, y):
	x = n * y / (2 * y + y * y + 1)
	lst = [x + y, x - y, x * y, x / y]
	return lst if all((v > 0 and v.is_integer() for v in lst)) else []


from itertools import count

def four_piles(apples, y):
	for x in count(2 * y, y):
		plus = x + y
		minus = x - y
		star = x * y
		slash = x / y
		total = plus + minus + star + slash
		if total == apples:
			return [plus, minus, star, slash]
		if total > apples:
			return []