In a far away country called AlgoLandia, there are `N` islands numbered `1` to `N`. Each island is denoted by `k[i]`. King Algolas, king of AlgoLandia, built `N - 1` bridges in the country. A bridge is built between islands `k[i]` and `k[i+1]`. Bridges are two-ways and are expensive to build.

The problem is that there are gangs who wants to destroy the bridges. In order to protect the bridges, the king wants to assign elite guards to the bridges. A bridge between islands `k[i]` and `k[i+1]` is safe when there is an elite guard in island `k[i]` or `k[i+1]`. There are already elite guards assigned in some islands.

Your task now is to determine the minimum number of additional elite guards that needs to be hired to guard all the bridges.

### Note:
You are given a sequence `k` with `N` length.
`k[i] = true`, means that there is an elite guard in that island; `k[i] = false` means no elite guard. It is guaranteed that AlgoLandia have at least `2` islands.

### Sample Input 1
```
k = [true, true, false, true, false]
```

### Sample Output 1
```
0
```

### Sample Input 2
```
k = [false, false, true, false, false]
```
### Sample Output 2
```
2
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Mathematics

Starter code: def find_needed_guards(k):
	

Solutions:
from itertools import groupby

def find_needed_guards(islands):
	return sum((sum((1 for _ in g)) >> 1 for (k, g) in groupby(islands) if not k))


def find_needed_guards(k):
	b = ''.join(('1' if g else '0' for g in k))
	return sum((len(ng) // 2 for ng in b.split('1')))


def find_needed_guards(k):
	prev = True
	guards = 0
	for i in k:
		if not i and (not prev):
			guards += 1
			prev = True
		else:
			prev = i
	return guards


from itertools import groupby

def find_needed_guards(k):
	return sum((len(list(g)) // 2 for (v, g) in groupby(k) if v == 0))


def find_needed_guards(k):
	return sum((len(i) // 2 for i in ''.join([('*', ' ')[i] for i in k]).split()))


def find_needed_guards(k):
	nbsold = 0
	i = 0
	while i < len(k) - 1:
		if k[i] == False and k[i + 1] == False:
			nbsold += 1
			i += 1
		i += 1
	return nbsold


def find_needed_guards(k):
	total = 0
	for i in range(1, len(k)):
		if k[i] == False:
			if k[i - 1] == False:
				total += 1
				k[i] = True
	return total


def find_needed_guards(k):
	total = 0
	for i in range(1, len(k)):
		if not (k[i] or k[i - 1]):
			k[i] = True
			total += 1
	return total


def find_needed_guards(k):
	if len(k) % 2 == 0:
		k.append(True)
	a = 0
	for x in range(1, len(k), 2):
		if k[x - 1] == k[x + 1] == True or k[x] == True:
			continue
		elif k[x - 1] == True:
			k[x + 1] = True
			a += 1
		else:
			a += 1
	return a