When multiple master devices are connected to a single bus (https://en.wikipedia.org/wiki/System_bus), there needs to be an arbitration in order to choose which of them can have access to the bus (and 'talk' with a slave).

We implement here a very simple model of bus mastering. Given `n`, a number representing the number of **masters** connected to the bus, and a fixed priority order (the first master has more access priority than the second and so on...), the task is to choose the selected master.
In practice, you are given a string `inp` of length `n` representing the `n` masters' requests to get access to the bus, and you should return a string representing the masters, showing which (only one) of them was granted access:

```
The string 1101 means that master 0, master 1 and master 3 have requested
access to the bus. 
Knowing that master 0 has the greatest priority, the output of the function should be: 1000
```

## Examples

## Notes

* The resulting string (`char* `) should be allocated in the `arbitrate` function, and will be free'ed in the tests.

* `n` is always greater or equal to 1.

Difficulty: EASY
Starter code: def arbitrate(s, n):
	

Solutions:
def arbitrate(s, n):
	i = s.find('1') + 1
	return s[:i] + '0' * (n - i)


def arbitrate(bus_str, n):
	return ''.join(['0' if i != bus_str.find('1') else '1' for (i, x) in enumerate(bus_str)])


def arbitrate(input, n):
	i = input.find('1')
	return input[:i + 1] + '0' * len(input[i + 1:])


def arbitrate(input, n):
	return '{:0{}b}'.format(2 ** int(input, 2).bit_length() // 2, n)


import re

def arbitrate(busAccess, n):
	return re.sub('(0*1)?(.*)', lambda m: (m.group(1) or '') + '0' * len(m.group(2)), busAccess)


arbitrate = lambda b, n: bin(int(2 ** (~-int(b, 2).bit_length())))[2:].zfill(n)


import re

def arbitrate(s, _):
	(p, m, b) = s.partition('1')
	return p + m + '0' * len(b)


def arbitrate(s, n):
	return ''.join(('1' if v == '1' and '1' not in s[:i] else '0' for (i, v) in enumerate(s)))


def arbitrate(inp, n):
	if '1' not in inp:
		return inp
	i = inp.index('1')
	return f"{'0' * i}1{(n - i - 1) * '0'}"