Mrs Jefferson is a great teacher. One of her strategies that helped her to reach astonishing results in the learning process is to have some fun with her students. At school, she wants to make an arrangement of her class to play a certain game with her pupils. For that, she needs to create the arrangement with **the minimum amount of groups that have consecutive sizes**.

Let's see. She has      ```14``` students. After trying a bit she could do the needed arrangement:
        ```[5, 4, 3, 2]```
- one group of  ```5``` students
- another group of      ```4``` students
- then, another one of  ```3``` 
- and finally, the smallest group of    ```2``` students.

As the game was a success, she was asked to help to the other classes to teach and show the game. That's why she desperately needs some help to make this required arrangements that make her spend a lot of time. 

To make things worse, she found out that there are some classes with some special number of students that is impossible to get that arrangement.

Please, help this teacher!

Your code will receive the number of students of the class. It should output the arrangement as an array with the consecutive sizes of the groups in decreasing order.

For the special case that no arrangement of the required feature is possible the code should output     ```[-1] ```

The value of n is unknown and may be pretty high because some classes joined to to have fun with the game.

You may see more example tests in the Example Tests Cases Box.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Mathematics

Starter code: def shortest_arrang(n):
	

Solutions:
def shortest_arrang(n):
	if n % 2 == 1:
		return [n // 2 + 1, n // 2]
	for i in range(3, n // 2):
		if i % 2 == 1 and n % i == 0:
			return list(range(n // i + i // 2, n // i - i // 2 - 1, -1))
		elif i % 2 == 0 and n % i == i // 2:
			return list(range(n // i + i // 2, n // i - i // 2, -1))
	return [-1]


def shortest_arrang(n):
	k = 1
	while n >= 0:
		n -= k
		k += 1
		(d, m) = divmod(n, k)
		if not m:
			return list(range(d + k - 1, d - 1, -1))
	return [-1]


def shortest_arrang(n):
	nGrpMax = int(((1 + 8 * n) ** 0.5 - 1) / 2)
	for nGrp in range(2, nGrpMax + 1):
		maxInG = (2 * n + nGrp ** 2 - nGrp) / (2 * nGrp)
		if maxInG == int(maxInG):
			maxInG = int(maxInG)
			return list(range(maxInG, maxInG - nGrp, -1))
	return [-1]


def shortest_arrang(n):
	r = n // 2 + 2
	a = [i for i in range(r, 0, -1)]
	for i in range(r):
		for j in range(r + 1):
			if sum(a[i:j]) == n:
				return a[i:j]
	return [-1]


def shortest_arrang(n):
	a = n // 2
	b = a + 1
	while a:
		total = sum(range(a, b + 1))
		if total == n:
			return list(range(b, a - 1, -1))
		if total > n:
			b -= 1
			a = b - 1
		else:
			a -= 1
	else:
		return [-1]


def shortest_arrang(num):
	for n in reversed(range((num + 3) // 2)):
		for j in reversed(range(n)):
			x = range(j, n + 1)
			if sum(x) == num:
				return list(reversed(x))
	return [-1]


def shortest_arrang(n):
	for i in range(2, n):
		if n / i * 2 < i:
			break
		if i % 2 == 0 and n / i % 1 == 0.5:
			return [n // i - i // 2 + 1 + j for j in range(0, i)[::-1]]
		if i % 2 == 1 and n / i % 1 == 0:
			return [n // i - (i - 1) // 2 + j for j in range(0, i)[::-1]]
	return [-1]


shortest_arrang = lambda n: (lambda ngm: next(((lambda x: list(range(x, x - ng, -1)))(int((2 * n + ng ** 2 - ng) / (2 * ng))) for ng in range(2, ngm + 1) if not (2 * n + ng ** 2 - ng) / (2 * ng) % 1), [-1]))(int(((1 + 8 * n) ** 0.5 - 1) / 2))