# Leaderboard climbers

In this kata you will be given a leaderboard of unique names for example:

```python
['John',
 'Brian',
 'Jim',
 'Dave',
 'Fred']
```

Then you will be given a list of strings for example:

```python
['Dave +1', 'Fred +4', 'Brian -1']
```

Then you sort the leaderboard.

The steps for our example would be:

```python
# Dave up 1
['John',
 'Brian',
 'Dave',
 'Jim',
 'Fred']
```

```python
# Fred up 4
['Fred',
 'John',
 'Brian',
 'Dave',
 'Jim']
```

```python
# Brian down 1
['Fred',
 'John',
 'Dave',
 'Brian',
 'Jim']
```

Then once you have done this you need to return the leaderboard.

All inputs will be valid. All strings in the second list will never ask to move a name up higher or lower than possible eg. `"John +3"` could not be added to the end of the second input list in the example above.

The strings in the second list will always be something in the leaderboard followed by a space and a `+` or `-` sign followed by a number.

Difficulty: EASY
Starter code: def leaderboard_sort(leaderboard, changes):
	

Solutions:
def leaderboard_sort(leaderboard, changes):
	for change in changes:
		(name, delta) = change.split()
		idx = leaderboard.index(name)
		leaderboard.insert(idx - int(delta), leaderboard.pop(idx))
	return leaderboard


def leaderboard_sort(lbd, changes):
	lbd = lbd[:]
	for (name, n) in map(str.split, changes):
		(n, i) = (int(n), lbd.index(name))
		lbd.pop(i)
		lbd.insert(i - n, name)
	return lbd


def leaderboard_sort(L, C):
	for c in C:
		(n, m) = c.split()
		i = L.index(n)
		L.pop(i)
		L.insert(i - eval(m), n)
	return L


def leaderboard_sort(leaderboard, changes):
	for change in changes:
		(name, move) = change.split()
		value_index = leaderboard.index(name)
		leaderboard.remove(name)
		leaderboard.insert(value_index - int(move), name)
	return leaderboard


def leaderboard_sort(leaderboard, changes):
	pos = leaderboard.copy()
	for (name, change) in map(str.split, changes):
		idx = pos.index(name)
		pos.insert(idx - int(change), pos.pop(idx))
	return pos


def leaderboard_sort(board, changes):
	for (i, e) in enumerate(changes):
		(name, point) = e.split()
		l = board.index(name)
		board.insert(int(eval(f'{l}-({point})')), board.pop(l))
	return board


def leaderboard_sort(leaderboard, changes):
	leaderboard.reverse()
	for (user, move) in [change.split() for change in changes]:
		index = leaderboard.index(user)
		leaderboard.remove(user)
		leaderboard.insert(eval('{}{}'.format(index, move)), user)
	leaderboard.reverse()
	return leaderboard


def leaderboard_sort(leaderboard, changes):
	for change in changes:
		(name, step) = change.split()
		step = int(step)
		idx = leaderboard.index(name)
		leaderboard.remove(name)
		leaderboard.insert(idx - step, name)
	return leaderboard


def leaderboard_sort(leaderboard, changes):
	change_dict = [(i.split()[0], int(i.split()[1])) for i in changes]
	leaderboard = leaderboard.copy()
	for (name, change) in change_dict:
		name_index = leaderboard.index(name)
		leaderboard.insert(name_index - change, leaderboard.pop(name_index))
	return leaderboard


def leaderboard_sort(leaderboard, changes):
	nleaderboard = leaderboard
	for change in changes:
		npos = int(change.split(' ')[1])
		name = change.split(' ')[0]
		pos = nleaderboard.index(name)
		if npos > 0:
			while npos != 0:
				(nleaderboard[pos - 1], nleaderboard[pos]) = (nleaderboard[pos], nleaderboard[pos - 1])
				npos = npos - 1
				pos = pos - 1
		elif npos < 0:
			while npos != 0:
				(leaderboard[pos + 1], leaderboard[pos]) = (leaderboard[pos], leaderboard[pos + 1])
				npos = npos + 1
				pos = pos + 1
	return nleaderboard


def leaderboard_sort(leaderboard, changes):
	for c in changes:
		curr = leaderboard.index(c.split()[0])
		leaderboard.insert(curr - int(c.split()[1]), leaderboard.pop(curr))
	return leaderboard


def leaderboard_sort(leaderboard, changes):
	for change in changes:
		(name, offset) = change.split(' ')
		pos = leaderboard.index(name)
		del leaderboard[pos]
		leaderboard.insert(pos - int(offset), name)
	return leaderboard


def leaderboard_sort(leaderboard, changes):
	leaderboard.reverse()
	length = len(leaderboard)
	for i in changes:
		temp = i.split(' ')
		k = temp[0]
		v = int(temp[1])
		for j in range(length):
			if leaderboard[j] == k:
				if j + v > length - 1:
					temp2 = leaderboard.pop(j)
					leaderboard.insert(0, temp2)
					break
				temp2 = leaderboard.pop(j)
				leaderboard.insert(j + v, temp2)
				break
	leaderboard.reverse()
	return leaderboard


def leaderboard_sort(lb, chn):
	for name in chn:
		(nm, diff) = tuple(name.split())
		diff = int(diff)
		ind = lb.index(nm)
		if diff > 0:
			lb.insert(ind - diff, nm)
			lb.pop(ind + 1)
		else:
			lb.insert(ind + abs(diff) + 1, nm)
			lb.pop(ind)
	print(lb)
	return lb


def leaderboard_sort(leaderboard, changes):
	for i in range(len(changes)):
		loc = leaderboard.index(changes[i].split(' ')[0])
		leaderboard.insert(loc - int(changes[i].split(' ')[1]), leaderboard.pop(loc))
	return leaderboard


leaderboard_sort = lambda l, c: (lambda u: ([([0 for u['i'] in [u['d'][o.split()[0]] - int(o.split()[1])]], [([0 for u['d'][k] in [u['d'][k] + 1]] if u['d'][o.split()[0]] > v >= u['i'] else None, [0 for u['d'][k] in [u['d'][k] - 1]] if u['d'][o.split()[0]] < v <= u['i'] else None) for (k, v) in u['d'].items()], [None for u['d'][o.split()[0]] in [u['i']]]) for o in c], sorted(u['d'].keys(), key=lambda x: u['d'][x]))[1])({'d': {l[i]: i for i in range(len(l))}, 'i': 0})


def leaderboard_sort(leaderboard, changes):
	data = []
	for change in changes:
		data.append(change.split(' '))
		data[-1][1] = int(data[-1][1])
	for change in data:
		curr_i = leaderboard.index(change[0])
		shift_i = curr_i - change[1]
		if change[1] < 0:
			leaderboard.insert(shift_i + 1, leaderboard[curr_i])
		else:
			leaderboard.insert(shift_i, leaderboard[curr_i])
		if shift_i < curr_i:
			leaderboard.pop(curr_i + 1)
		else:
			leaderboard.pop(curr_i)
	return leaderboard


def leaderboard_sort(leaderboard, changes):
	for rec in changes:
		(name, move) = rec.split()
		curr_position = leaderboard.index(name)
		del leaderboard[curr_position]
		new_position = curr_position - int(move)
		leaderboard.insert(new_position, name)
	return leaderboard


def leaderboard_sort(leaderboard, changes):
	for change in changes:
		(name, pos) = change.split()
		old_pos = leaderboard.index(name)
		new_pos = eval(f'{old_pos}-{pos}')
		if old_pos < new_pos:
			leaderboard = leaderboard[:old_pos] + leaderboard[old_pos + 1:new_pos + 1] + [name] + leaderboard[new_pos + 1:]
		else:
			leaderboard = leaderboard[:new_pos] + [name] + leaderboard[new_pos:old_pos] + leaderboard[old_pos + 1:]
	return leaderboard


def leaderboard_sort(leaderboard, changes):
	adjustments = leaderboard
	for change in changes:
		adjustment_num = int(change.split(' ')[1])
		name = change.split(' ')[0]
		new_place = adjustments.index(name) - adjustment_num
		adjustments.pop(adjustments.index(name))
		adjustments.insert(new_place, name)
	return adjustments