You've made it through the moat and up the steps of knowledge. You've won the temples games and now you're hunting for treasure in the final temple run. There's good news and bad news. You've found the treasure but you've triggered a nasty trap. You'll surely perish in the temple chamber.

With your last movements, you've decided to draw an "X" marks the spot for the next archeologist.

Given an odd number, n, draw an X for the next crew. Follow the example below.

`
`
If n = 1 return 'X\n' and if you're given an even number or invalid input, return '?'.

The output should be a string with no spaces after the final X on each line, but a \n to indicate a new line.


Check out my other 80's Kids Katas:


80's Kids #1: How Many Licks Does It Take
80's Kids #2: Help Alf Find His Spaceship
80's Kids #3: Punky Brewster's Socks
80's Kids #4: Legends of the Hidden Temple
80's Kids #5: You Can't Do That on Television
80's Kids #6: Rock 'Em, Sock 'Em Robots
80's Kids #7: She's a Small Wonder
80's Kids #8: The Secret World of Alex Mack
80's Kids #9: Down in Fraggle Rock 
80's Kids #10: Captain Planet

Source: codewars | Difficulty: EASY
Tags: Game theory

Starter code: def mark_spot(n):
	

Solutions:
def mark_spot(n):
	if not isinstance(n, int) or not n % 2 or n < 1:
		return '?'
	spots = [[' '] * n for _ in range(n)]
	for (i, row) in enumerate(spots):
		(row[i], row[-1 - i]) = 'XX'
	return '\n'.join((' '.join(row).rstrip() for row in spots + ['']))


def mark_spot(n):
	if type(n) is not int or n <= 0 or n % 2 == 0:
		return '?'
	(p1, s) = (0, 2 * n - 3)
	result = ''
	for i in range(1, n // 2 + 1):
		result += ' ' * p1 + 'X' + ' ' * s + 'X\n'
		p1 += 2
		s -= 4
	result += ' ' * p1 + 'X\n'
	for i in range(n // 2 + 2, n + 1):
		p1 -= 2
		s += 4
		result += ' ' * p1 + 'X' + ' ' * s + 'X\n'
	return result


from itertools import chain

def mark_spot(n):
	if not (isinstance(n, int) and n % 2 and (n > 0)):
		return '?'
	result = []
	row_length = n * 2 - 1
	for a in chain(range(0, n, 2), range(n - 3, -1, -2)):
		row = [' '] * row_length
		row[a] = 'X'
		row[-(a + 1)] = 'X\n'
		result.append(''.join(row).rstrip(' '))
	return ''.join(result)


def mark_spot(n):
	if not (isinstance(n, int) and n > 0 and n % 2):
		return '?'
	w = n * 2 - 1
	return ''.join((''.join(('X' if j in (i, w - 1 - i) else ' ' for j in range(w))).rstrip() + '\n' for i in range(0, n * 2, 2)))


def mark_spot(n):
	return '?' if not isinstance(n, int) or n < 1 or n % 2 == 0 else '\n'.join(('{0}{1}{0}'.format('X' if i != n // 2 else '', ' ' * (abs(n - 1 - 2 * i) * 2 - 1) if i != n // 2 else 'X').center(n * 2).rstrip() for i in range(n))) + '\n'


def mark_spot(n):
	if not type(n) == int or n < 1 or (not n % 2):
		return '?'
	l = [' ' * (2 * n - i * 2) for i in range(n // 2 + 1)]
	for i in range(len(l)):
		l[i] = l[i][:-2] + 'X' + '\n'
		l[i] = ' ' * i * 2 + 'X' + l[i][i * 2 + 1:]
	return ''.join(l + l[::-1][1:])


def mark_spot(n):
	if not isinstance(n, int) or n < 0 or n % 2 != 1:
		return '?'
	ans = [[' '] * (2 * n - 1) for _ in range(n)]
	for i in range(n):
		ans[i][i * 2] = ans[i][2 * n - 2 * i - 2] = 'X'
	return '\n'.join((''.join(a).rstrip() for a in ans)) + '\n'


def mark_spot(n):
	if not isinstance(n, int):
		return '?'
	if n % 2 == 0 or n < 1:
		return '?'
	res = ''
	demi = n // 2
	for i in range(demi):
		for j in range(2 * i):
			res += ' '
		res += 'X'
		for j in range(4 * (demi - i) - 1):
			res += ' '
		res += 'X\n'
	for j in range(2 * demi):
		res += ' '
	res += 'X\n'
	for i in reversed(list(range(demi))):
		for j in range(2 * i):
			res += ' '
		res += 'X'
		for j in range(4 * (demi - i) - 1):
			res += ' '
		res += 'X\n'
	return res