You managed to send your friend to queue for tickets in your stead, but there is a catch: he will get there only if you tell him how much that is going to take. And everybody can only take one ticket at a time, then they go back in the last position of the queue if they need more (or go home if they are fine).

Each ticket takes one minutes to emit, the queue is well disciplined, [Brit-style](https://www.codewars.com/kata/english-beggars), and so it moves smoothly, with no waste of time.

You will be given an array/list/vector with all the people queuing and the *initial* position of your buddy, so for example, knowing that your friend is in the third position (that we will consider equal to the index, `2`: he is the guy that wants 3 tickets!) and the initial queue is `[2, 5, 3, 4, 6]`.

The first dude gets his ticket and the queue goes now like this `[5, 3, 4, 6, 1]`, then `[3, 4, 6, 1, 4]` and so on. In the end, our buddy will be queuing for 12 minutes, true story!

Build a function to compute it, resting assured that only positive integers are going to be there and you will be always given a valid index; but we also want to go to pretty popular events, so be ready for big queues with people getting plenty of tickets.

[[hard core version](https://www.codewars.com/kata/queue-time-counter-hard-core-version/solutions/javascript) now available if you don't want the "easy" kata!]

Difficulty: EASY
Tags: Data structures
Skill types: Data structures

Starter code:
def queue(queuers,pos):
	

Solutions:
def queue(queuers, pos):
	return sum((min(queuer, queuers[pos] - (place > pos)) for (place, queuer) in enumerate(queuers)))


def queue(queuers, pos):
	friendWait = queuers[pos]
	frontOfLine = queuers[:pos + 1]
	backOfLine = queuers[pos + 1:]
	frontOfLine = [min(x, friendWait) for x in frontOfLine]
	backOfLine = [min(x, friendWait - 1) for x in backOfLine]
	return sum(frontOfLine) + sum(backOfLine)


def queue(queuers, pos):
	return sum((min(q, queuers[pos]) for q in queuers)) - sum((1 for q in queuers[pos + 1:] if q >= queuers[pos]))


def queue(q, pos):
	time = 0
	while True:
		time += 1
		if q[0] == 1:
			if pos:
				q.pop(0)
			else:
				return time
		else:
			q.append(q.pop(0) - 1)
		pos = pos - 1 if pos else len(q) - 1


def queue(q, pos):
	return sum((min(x, q[pos]) for x in q[:pos + 1])) + sum((min(x, q[pos] - 1) for x in q[pos + 1:]))


def queue(queuers, pos, time=0):
	while True:
		for i in range(len(queuers)):
			if queuers[pos] == 0:
				return time
			elif queuers[i]:
				queuers[i] -= 1
				time += 1


def queue(q, pos, r=0):
	while True:
		r += 1
		q[0] -= 1
		if q[pos] == 0:
			return r
		q = q[1:] + [q[0]] if q[0] > 0 else q[1:]
		pos -= 1
		if pos < 0:
			pos = len(q) - 1


def queue(queuers, pos):
	count = 0
	while len(queuers) != 0:
		k = queuers.pop(0)
		count += 1
		if k - 1 != 0:
			queuers.append(k - 1)
			if pos == 0:
				pos = len(queuers) - 1
			else:
				pos -= 1
		elif k - 1 == 0 and pos == 0:
			break
		else:
			pos -= 1
	return count


def queue(queuers, pos):
	count = 0
	while queuers[pos] > 0:
		if pos == 0:
			pos = len(queuers) - 1
		else:
			pos -= 1
		queuers[0] -= 1
		queuers.append(queuers[0])
		queuers.pop(0)
		count += 1
	return count + sum([i for i in queuers if i < 0])


def queue(queuers, pos):
	min = 0
	while queuers[pos] > 0:
		for i in range(0, len(queuers)):
			if queuers[i] > 0:
				queuers[i] -= 1
				min += 1
			if queuers[pos] == 0:
				break
	return min