# Task
 Given some points(array `A`) on the same line, determine the minimum number of line segments with length `L` needed to cover all of the given points. A point is covered if it is located inside some segment or on its bounds.

# Example

 For `A = [1, 3, 4, 5, 8]` and `L = 3`, the output should be `2`.

 Check out the image below for better understanding:

![](https://codefightsuserpics.s3.amazonaws.com/tasks/segmentCover/img/example.png?_tm=1474900035857)

 
 For `A = [1, 5, 2, 4, 3]` and `L = 1`, the output should be `3`.
 
 segment1: `1-2`(covered points 1,2), 
 
 segment2: `3-4`(covered points 3,4),
 
 segment3: `5-6`(covered point 5)

 For `A = [1, 10, 100, 1000]` and `L = 1`, the output should be `4`.
 
 segment1: `1-2`(covered point 1), 
 
 segment2: `10-11`(covered point 10),
 
 segment3: `100-101`(covered point 100), 
 
 segment4: `1000-1001`(covered point 1000)


# Input/Output


 - `[input]` integer array A

    Array of point coordinates on the line (all points are different).

    Constraints:

    `1 ≤ A.length ≤ 50,`

    `-5000 ≤ A[i] ≤ 5000.`


 - `[input]` integer `L`

    Segment length, a positive integer.

    Constraints: `1 ≤ L ≤ 100.`


 - `[output]` an integer
 
   The minimum number of line segments that can cover all of the given points.

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

Starter code: def segment_cover(A, L):
	

Solutions:
def segment_cover(A, L):
	n = 1
	s = min(A)
	for i in sorted(A):
		if s + L < i:
			s = i
			n += 1
	return n


def segment_cover(a, l):
	(a, n) = (set(a), 0)
	while a:
		a -= set(range(min(a), min(a) + l + 1))
		n += 1
	return n


def segment_cover(A, L):
	A = sorted(A)
	nb_segments = 0
	while A:
		nb_segments += 1
		first_elt = A.pop(0)
		while A and A[0] <= first_elt + L:
			A.pop(0)
	return nb_segments


def segment_cover(A, L):
	A = sorted(A)
	segment_end = A[0] - 1
	segments = 0
	for point in A:
		if point > segment_end:
			segments += 1
			segment_end = point + L
	return segments


def segment_cover(A, L):
	end = None
	count = 0
	for a in sorted(A):
		if end and a <= end:
			continue
		else:
			end = a + L
			count += 1
	return count


def segment_cover(points, length):
	(n, e) = (0, float('-inf'))
	for p in sorted(points):
		if e < p:
			e = p + length
			n += 1
	return n


def segment_cover(A, l):
	A = set(A)
	m = min(A)
	c = 0
	while A:
		A = {a for a in A if a > m + l}
		c += 1
		if A:
			m = min(A)
		else:
			return c


def segment_cover(a, l):
	s = 0
	while a:
		L = min(a) + l
		a = [v for v in a if v > L]
		s += 1
	return s


def segment_cover(A, L):
	c = 0
	while A:
		c += 1
		seg = min(A, default=0)
		A = list([item for item in A if item > seg + L])
	return c


def segment_cover(a, n):
	a.sort()
	(r, c) = (1, a[0])
	for x in a:
		if x - c > n:
			r += 1
			c = x
	return r