Variation of this nice kata, the war has expanded and become dirtier and meaner; both even and odd numbers will fight with their pointy `1`s. And negative integers are coming into play as well, with, ça va sans dire, a negative contribution (think of them as spies or saboteurs).

Again, three possible outcomes: `odds win`, `evens win` and `tie`.

Examples:

```python
bits_war([1,5,12]) => "odds win" #1+101 vs 1100, 3 vs 2
bits_war([7,-3,20]) => "evens win" #111-11 vs 10100, 3-2 vs 2
bits_war([7,-3,-2,6]) => "tie" #111-11 vs -1+110, 3-2 vs -1+2
```

Source: codewars | Difficulty: EASY
Tags: Bit manipulation

Data structures

Fundamentals

Starter code: def bits_war(numbers):
	

Solutions:
def bits_war(numbers):
	(odd, even) = (0, 0)
	for number in numbers:
		if number % 2 == 0:
			if number > 0:
				even += bin(number).count('1')
			else:
				even -= bin(number).count('1')
		elif number > 0:
			odd += bin(number).count('1')
		else:
			odd -= bin(number).count('1')
	return 'odds win' if odd > even else 'evens win' if even > odd else 'tie'


bits_war = lambda n: (lambda s: 'evens win' if s > 0 else 'odds win' if s else 'tie')(sum((bin(d)[2:].count('1') * (-1) ** ((d % 2 or d < 0) - (d % 2 and d < 0)) for d in n)))


def bits_war(numbers):
	FIGHT = sum((sum(map(int, bin(abs(n))[2:])) * (-1) ** (n < 0) * (-1) ** (n % 2 == 0) for n in numbers))
	return ['evens win', 'tie', 'odds win'][(FIGHT >= 0) + (FIGHT > 0)]


def bits_war(numbers):
	evens = sum([bin(numb).replace('0b', '').count('1') * (-1 if '-' in bin(numb) else 1) for numb in numbers if numb % 2 == 0])
	odds = sum([bin(numb).replace('0b', '').count('1') * (-1 if '-' in bin(numb) else 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_war(numbers):
	(even, odd) = (0, 0)
	for x in numbers:
		res = bin(x).count('1')
		res = -res if x < 0 else res
		if x % 2:
			odd += res
		else:
			even += res
	return 'tie' if even == odd else ('even', 'odd')[odd > even] + 's win'


def bits_war(numbers):
	scores = sum((f'{n:b}'.count('1') * (-1) ** (n % 2 == (n > 0)) for n in numbers))
	return f"{['odds', 'evens'][scores > 0]} win" if scores else 'tie'


def bits_war(numbers):
	res = [0, 0]
	for x in filter(None, numbers):
		res[x & 1] += bin(x).count('1') * x // abs(x)
	return 'odds win' if res[0] < res[1] else 'evens win' if res[0] > res[1] else 'tie'


def bits_war(numbers):
	(odd_score, even_score) = (score((x for x in numbers if x % 2)), score((x for x in numbers if x % 2 == 0)))
	return 'odds win' if odd_score > even_score else 'tie' if odd_score == even_score else 'evens win'

def score(numbers):
	return sum((bin(x)[2:].count('1') * [-1, 1][x > 0] for x in numbers))


def bits_war(numbers):
	(even, odd) = (sum((bin(x).count('1') * (1 if x > 0 else -1) for x in numbers if x % 2 == remainder)) for remainder in [0, 1])
	return 'odds win' if odd > even else 'evens win' if even > odd else 'tie'