The odd and even numbers are fighting against each other!

You are given a list of positive integers. The odd numbers from the list will fight using their `1` bits from their binary representation, while the even numbers will fight using their `0` bits. If present in the list, number `0` will be neutral, hence not fight for either side.

You should return:

* `odds win` if number of `1`s from odd numbers is larger than `0`s from even numbers
* `evens win` if number of `1`s from odd numbers is smaller than `0`s from even numbers
* `tie` if equal, including if list is empty

Please note that any prefix that might appear in the binary representation, e.g. `0b`, should not be counted towards the battle.

### Example:
For an input list of `[5, 3, 14]`:

* odds: `5` and `3` => `101` and `11` => four `1`s
* evens: `14` => `1110` => one `0`

Result: `odds win` the battle with 4-1

If you enjoyed this kata, you can find a nice variation of it [here](https://www.codewars.com/kata/world-bits-war).

Source: codewars | Difficulty: EASY
Tags: Bit manipulation

Fundamentals

Starter code: def bits_battle(numbers):
	

Solutions:
def bits_battle(nums):
	binary = '{:b}'.format
	evens = odds = 0
	for num in nums:
		if num % 2:
			odds += binary(num).count('1')
		else:
			evens += binary(num).count('0')
	if odds == evens:
		return 'tie'
	return '{} win'.format('odds' if odds > evens else 'evens')


def bits_battle(a):
	(odds, evens) = (sum([bin(i).count('1') for i in a if i % 2]), sum([bin(i).count('0') - 1 for i in a if i % 2 == 0]))
	return 'odds win' if odds > evens else 'evens win' if evens > odds else 'tie'


def bits_battle(numbers):
	x = sum((format(n, 'b').count('1') if n % 2 else -format(n, 'b').count('0') for n in numbers if n))
	return 'odds win' if x > 0 else 'evens win' if x < 0 else 'tie'


def bits_battle(numbers):
	evens = sum([bin(numb).replace('0b', '').count('0') for numb in numbers if numb % 2 == 0])
	odds = sum([bin(numb).replace('0b', '').count('1') for numb in numbers if numb % 2 != 0])
	return 'odds win' if odds > evens else 'evens win' if evens > odds else 'tie'


def bits_battle(numbers):
	res = [0, 0]
	for x in numbers:
		res[x & 1] += bin(x)[2:].count('01'[x & 1])
	return 'odds win' if res[0] < res[1] else 'evens win' if res[0] > res[1] else 'tie'


def bits_battle(numbers):
	odds = 0
	evens = 0
	for n in numbers:
		if n % 2:
			odds += bin(n).count('1')
		elif n != 0 and n % 2 == 0:
			evens += bin(n)[2:].count('0')
	return 'odds win' if odds > evens else 'evens win' if evens > odds else 'tie'


def bits_battle(numbers):
	(odds, evens) = (sum((bin(n).count('1') for n in numbers if n % 2)), sum((bin(n).count('0') - 1 for n in numbers if not n % 2)))
	return ['odds win', 'evens win'][odds - evens < 0] if odds - evens else 'tie'


bits_battle = lambda a: {'0': 'tie', '-': 'odds win'}.get(str(sum(((-1) ** (x % 2) * bin(x)[2:].count(str(x % 2)) for x in a if x)))[0], 'evens win')