# Task
N lamps are placed in a line, some are switched on and some are off. What is the smallest number of lamps that need to be switched so that on and off lamps will alternate with each other? 

You are given an array `a` of zeros and ones - `1` mean switched-on lamp and `0` means switched-off.

Your task is to find the smallest number of lamps that need to be switched.

# Example

For `a = [1, 0, 0, 1, 1, 1, 0]`, the result should be `3`.
```
a     --> 1 0 0 1 1 1 0
swith --> 0 1     0
became--> 0 1 0 1 0 1 0 ```

# Input/Output


- `[input]` integer array `a`

array of zeros and ones - initial lamp setup, 1 mean switched-on lamp and 0 means switched-off.

`2 < a.length <= 1000`


- `[output]` an integer

minimum number of switches.

Source: codewars | Difficulty: EASY
Tags: Ad-hoc

Starter code: def lamps(a):
	

Solutions:
def lamps(a):
	n = sum((1 for (i, x) in enumerate(a) if x != i % 2))
	return min(n, len(a) - n)


def lamps(a):
	case1c = 0
	case2c = 0
	for i in range(len(a)):
		if i % 2 == 0:
			if a[i] == 1:
				case1c += 1
			else:
				case2c += 1
		elif a[i] == 1:
			case2c += 1
		else:
			case1c += 1
	return min(case1c, case2c)


def lamps(lst):
	starts_with_zero = sum((on ^ i & 1 for (i, on) in enumerate(lst)))
	starts_with_one = sum((on ^ i & 1 for (i, on) in enumerate(lst, 1)))
	return min(starts_with_zero, starts_with_one)


import copy

def lamps(a):
	k = 0
	n = []
	b = copy.deepcopy(a)
	print(a)
	for c in range(1, len(a)):
		if a[c] == a[c - 1]:
			a[c] = 1 - a[c]
			k += 1
	if k == 0:
		return 0
	n.append(k)
	print(n)
	k = 1
	b[0] = 1 - b[0]
	print(b)
	for c in range(1, len(b)):
		if b[c] == b[c - 1]:
			b[c] = 1 - b[c]
			k += 1
	n.append(k)
	print(n)
	return min(n)


def lamps(a):
	r = sum((x == c % 2 for (c, x) in enumerate(a)))
	return min(r, len(a) - r)


def lamps(a):
	(i, count) = (0, 0)
	for lamp in a:
		if lamp == i % 2:
			count += 1
		i += 1
	return min(count, i - count)


from itertools import cycle

def lamps(a):
	dif = lambda a, b: sum((x != y for (x, y) in zip(a, b)))
	return min(dif(a, cycle([1, 0])), dif(a, cycle([0, 1])))