There's a waiting room with N chairs set in single row. Chairs are consecutively numbered from 1 to N. First is closest to the entrance (which is exit as well).
 
For some reason people choose a chair in the following way

1. Find a place as far from other people as possible
2. Find a place as close to exit as possible

All chairs must be occupied before the first person will be served

So it looks like this for 10 chairs and 10 patients




Chairs
1
2
3
4
5
6
7
8
9
10




Patients
1
7
5
8
3
9
4
6
10
2




Your task is to find last patient's chair's number. 

Input - N - integer greater than 2 - number of chairs.
Output should positive integer too - last patient's chair's number

Have fun :)

Source: codewars | Difficulty: EASY
Tags: Sorting

Ad-hoc

Starter code: def last_chair(n):
	

Solutions:
def last_chair(n):
	return n - 1


last_chair = lambda n: n - 1


def last_chair(n):
	return n if n < 3 else n - 1


def last_chair(n):
	if n == 1 or n == 2:
		return n
	else:
		return n - 1


def last_chair(n):
	return n - 1
	spots = [[i, False, None, None, None, None] for i in range(n)]
	clean = lambda n, d=0: n if n is not None else d
	live = lambda s: not s[1]
	position = lambda s: s[0]
	near = lambda s: s[4]
	spaces = lambda s: s[5]
	while any(filter(live, spots)):
		nearest = None
		for i in range(n):
			if spots[i][1]:
				nearest = 0
			elif nearest is not None:
				nearest += 1
			spots[i][2] = nearest
		nearest = None
		for i in range(n - 1, -1, -1):
			if spots[i][1]:
				nearest = 0
			elif nearest is not None:
				nearest += 1
			spots[i][3] = nearest
		for i in range(n):
			spots[i][4] = min(clean(spots[i][2], n), clean(spots[i][3], n))
			spots[i][5] = clean(spots[i][2]) + clean(spots[i][3])
		options = list(filter(live, spots))
		options.sort(key=near, reverse=True)
		best = near(options[0])
		options = [s for s in options if near(s) == best]
		options.sort(key=spaces, reverse=True)
		best = spaces(options[0])
		options = [s for s in options if spaces(s) == best]
		options.sort(key=position)
		options[0][1] = True
		result = position(options[0])
	return result + 1


last_chair = 1 .__rsub__