Your job is to change the given string `s` using a non-negative integer `n`.

Each bit in `n` will specify whether or not to swap the case for each alphabetic character in `s`: if the bit is `1`, swap the case; if its `0`, leave it as is. When you finished with the last bit of `n`, start again with the first bit.

You should skip the checking of bits when a non-alphabetic character is encountered, but they should be preserved in their original positions.

## Examples

```
swap('Hello world!', 11)  -->  'heLLO wORLd!'
```
...because `11` is `1011` in binary, so the 1st, 3rd, 4th, 5th, 7th, 8th and 9th alphabetical characters have to be swapped:
```
H e l l o  w o r l d !
1 0 1 1 1  0 1 1 1 0
^   ^ ^ ^    ^ ^ ^
```

More examples:
```
swap("gOOd MOrniNg", 7864)  -->  "GooD MorNIng"
swap('', 11345)  -->  ''
swap('the lord of the rings', 0)  -->  'the lord of the rings'
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def swap(s,n):
	

Solutions:
from itertools import cycle

def swap(s, n):
	b = cycle(bin(n)[2:])
	return ''.join((c.swapcase() if c.isalpha() and next(b) == '1' else c for c in s))


from itertools import cycle

def swap(s, n):
	doSwap = cycle(map(int, f'{n:b}'))
	return ''.join((c.swapcase() if c.isalpha() and next(doSwap) else c for c in s))


def swap(s, n):
	n = str(bin(n))[2:]
	index = 0
	new_s = ''
	for letter in s:
		if letter.isalpha():
			if n[index % len(n)] == '1':
				new_s += letter.swapcase()
			else:
				new_s += letter
			index += 1
		else:
			new_s += letter
	return new_s


from itertools import cycle

def swap(s, n):
	binary = cycle(bin(n)[2:])
	return ''.join((char.swapcase() if char.isalpha() and next(binary) == '1' else char for char in s))


from itertools import cycle

def swap(s, n):
	it = cycle(bin(n)[2:])
	return ''.join((x.swapcase() if x.isalpha() and next(it) == '1' else x for x in s))


def swap(s, n):
	(bits, r, c) = (bin(n)[2:], '', 0)
	for i in s:
		r += [i, i.swapcase()][int(bits[c % len(bits)])]
		c += i.isalpha()
	return r


def swap(s, n):
	n = str(bin(n))[2:]
	words = list(s)
	binary_mult = str(n) * len(s)
	bn_words = list(binary_mult)
	result = []
	for (i, x) in enumerate(words):
		if not x.isalpha():
			bn_words.insert(i, x)
		if bn_words[i] == '1':
			result.append(words[i].swapcase())
		else:
			result.append(words[i])
	return ''.join(result)


from itertools import cycle

def swap(s, n):
	return (lambda N: ''.join((e if not e.isalpha() else (e, e.swapcase())[next(N)] for e in s)))(cycle(map(int, bin(n)[2:])))


from itertools import cycle

def swap(s, n):
	it = cycle(map(int, format(n, 'b')))
	return ''.join((c.swapcase() if c.isalpha() and next(it) else c for c in s))