How many days are we represented in a foreign country?

My colleagues make business trips to a foreign country. We must find the number of days our company is represented in a country. Every day that one or more colleagues are present in the country is a day that the company is represented. A single day cannot count for more than one day.

Write a function that recieves a list of pairs and returns the number of days that the company is represented in the foreign country. The first number of the pair is the number of the day of arrival and the second number of the pair is the day of departure of someone who travels, i.e. 1 january is number 1 and 31 of december is 365.

Example:
```python
days_represented([[10,17],[200,207]])
```

Returns 16 because there are two trips of 8 days, which add up to 16.

Happy coding and rank this kata if you wish ;-)

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Starter code: def days_represented(trips):
	

Solutions:
def days_represented(a):
	return len({i for (x, y) in a for i in range(x, y + 1)})


def days_represented(trips):
	L = []
	for i in trips:
		for j in range(i[0], i[1] + 1):
			L.append(j)
	a = set(L)
	return len(a)


def days_represented(trips):
	return len({i for (start, stop) in trips for i in range(start, stop + 1)})


def days_represented(trips):
	arr = [0] * 365
	for (a, b) in trips:
		arr[a:b + 1] = [1] * (b - a + 1)
	return sum(arr)


def days_represented(trips):
	total = 0
	visited = []
	for i in range(len(trips)):
		trip = trips[i]
		arrival = trip[1]
		departure = trip[0]
		for j in range(departure, arrival + 1):
			if j not in visited:
				visited.append(j)
			else:
				continue
	return len(visited)


def days_represented(trips):
	trips.sort()
	print(trips)
	previous_end = trips[0][1]
	days = previous_end - trips[0][0] + 1
	trips.pop(0)
	for trip in trips:
		(start, end) = trip
		if start > previous_end:
			days += end - start + 1
			previous_end = end
		elif end > previous_end:
			days += end - previous_end
			previous_end = end
	return days


def days_represented(trips):
	accumulator = set()
	for (a, b) in trips:
		accumulator |= set(range(a, b + 1))
	return len(accumulator)


def days_represented(trips):
	new = []
	for days in trips:
		for day in range(days[0], days[1] + 1):
			new.append(day)
	p = set(new)
	return len(p)


from itertools import chain

def days_represented(trips):
	return len(set(chain(*(range(a, b + 1) for (a, b) in trips))))