Given the number n, return a string which shows the minimum number of moves to complete the tower of Hanoi consisting of n layers.
Tower of Hanoi : https://en.wikipedia.org/wiki/Tower_of_Hanoi

Example - 2 layered Tower of Hanoi 

Input: n=2

Start
[[2, 1], [], []]

Goal
[[], [], [2, 1]]

Expected Output : '[[2, 1], [], []]\n[[2], [1], []]\n[[], [1], [2]]\n[[], [], [2, 1]]'

Source: codewars | Difficulty: EASY

Starter code: def hanoiArray(n):
	

Solutions:
def hanoiArray(n):
	(A, B, C) = (list(range(n, 0, -1)), [], [])
	res = [str([A, C, B])]

	def rec(n, X, Y, Z):
		if not n:
			return
		rec(n - 1, X, Z, Y)
		Y.append(X.pop())
		res.append(str([A, C, B]))
		rec(n - 1, Z, Y, X)
	rec(n, A, B, C)
	return '\n'.join(res)


from io import StringIO

def move(n, a, b, c, source, target, auxiliary, output):
	if n > 0:
		move(n - 1, a, b, c, source, auxiliary, target, output)
		target.append(source.pop())
		print([a, b, c], file=output)
		move(n - 1, a, b, c, auxiliary, target, source, output)

def hanoiArray(n):
	(a, b, c) = (list(range(n, 0, -1)), [], [])
	with StringIO() as output:
		print([a, b, c], file=output)
		move(n, a, b, c, a, c, b, output)
		return output.getvalue().rstrip('\n')


m = lambda n, l, a, b, c: n and m(n - 1, l, a, c, b) + [l[c].append(l[a].pop()) or str(l)] + m(n - 1, l, b, a, c) or []
hanoiArray = lambda n: (lambda l: str(l) + '\n' + '\n'.join(map(str, m(n, l, 0, 1, 2))))([list(range(n, 0, -1)), [], []])


def maketrans(n, a, b, c):
	if n == 0:
		return []
	return maketrans(n - 1, a, c, b) + [[a, b]] + maketrans(n - 1, c, b, a)

def hanoiArray(n):
	transitions = maketrans(n, 0, 2, 1)
	state = [[i for i in range(n, 0, -1)], [], []]
	res = str(state)
	while transitions:
		(from_peg, to_peg) = transitions.pop(0)
		state[to_peg].append(state[from_peg].pop())
		res += '\n' + str(state)
	return res


def hanoiArray(n):

	def move(n, source, target, auxiliary):
		if n > 0:
			move(n - 1, source, auxiliary, target)
			target.append(source.pop())
			res.append([A[:], B[:], C[:]])
			move(n - 1, auxiliary, target, source)
	A = list(range(n, 0, -1))
	B = []
	C = []
	res = [[A[:], B[:], C[:]]]
	move(n, A, C, B)
	return '\n'.join(map(str, res))


def hanoiArray(n):
	initial = [x for x in range(n, 0, -1)]
	tow = [initial, [], []]
	ret = str(tow)

	def move(f, t):
		nonlocal tow, ret
		tow[t].append(tow[f].pop())
		ret = ret + '\n' + str(tow)

	def solve(n, f, h, t):
		if n == 0:
			pass
		else:
			solve(n - 1, f, t, h)
			move(f, t)
			solve(n - 1, h, f, t)
	solve(n, 0, 1, 2)
	return ret


def Hanoi_Solution(n):
	if n == 0:
		return [[], [], []]
	if n == 1:
		return [[[1], [], []], [[], [], [1]]]
	else:
		L = len(Hanoi_Solution(n - 1))
		first_half = Hanoi_Solution(n - 1)
		for i in range(L):
			first_half[i][0].insert(0, n)
			temp_1 = first_half[i][2]
			first_half[i][2] = first_half[i][1]
			first_half[i][1] = temp_1
		second_half = Hanoi_Solution(n - 1)
		for i in range(L):
			second_half[i][2].insert(0, n)
			temp_2 = second_half[i][1]
			second_half[i][1] = second_half[i][0]
			second_half[i][0] = temp_2
		for i in second_half:
			first_half.append(i)
		return first_half

def hanoiArray(n):
	return ''.join((str(i) + '\n' for i in Hanoi_Solution(n)))[:-1]


def hanoi(n, a, b):
	if n == 1:
		return [(a, b)]
	else:
		c = 3 - a - b
		return hanoi(n - 1, a, c) + [(a, b)] + hanoi(n - 1, c, b)

def hanoiArray(n):
	moves = hanoi(n, 0, 2)
	towers = [list(range(n, 0, -1)), [], []]
	ans = [str(towers)]
	for (i, j) in moves:
		towers[j].append(towers[i].pop())
		ans.append(str(towers))
	return '\n'.join(ans)