# A History Lesson

The Pony Express was a mail service operating in the US in 1859-60.




It reduced the time for messages to travel between the Atlantic and Pacific coasts to about 10 days, before it was made obsolete by the [transcontinental telegraph](https://en.wikipedia.org/wiki/First_transcontinental_telegraph).

# How it worked

There were a number of *stations*, where:

* The rider switched to a fresh horse and carried on, or
* The mail bag was handed over to the next rider


# Kata Task

`stations` is a list/array of distances (miles) from one station to the next along the Pony Express route.

Implement the `riders` method/function, to return how many riders are necessary to get the mail from one end to the other.

**NOTE:** Each rider travels as far as he can, but never more than 100 miles.

---
*Good Luck.
DM.*

---

See also

* The Pony Express
* The Pony Express (missing rider)

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def riders(stations):
	

Solutions:
def riders(stations):
	(riders, travelled) = (1, 0)
	for dist in stations:
		if travelled + dist > 100:
			riders += 1
			travelled = dist
		else:
			travelled += dist
	return riders


def riders(stations):
	n = 1
	acc = 0
	for x in stations:
		acc += x
		if acc > 100:
			acc = x
			n += 1
	return n


def riders(A):
	Z = [0]
	for x in A:
		if Z[-1] + x <= 100:
			Z[-1] += x
		else:
			Z.append(x)
	return len(Z)


def riders(stations):
	(c, acc) = (0, 0)
	for d in stations:
		c += acc + d > 100
		acc = d if acc + d > 100 else acc + d
	return c + bool(acc)


def riders(stations):
	res = 0
	rdistance = 0
	for i in stations:
		if rdistance + i > 100:
			rdistance = i
			res += 1
		else:
			rdistance += i
	return res + 1


def riders(a):
	i = r = 0
	while i < len(a):
		n = next((k for k in range(i, len(a)) if sum(a[i:k + 1]) > 100), len(a))
		r += 1
		i = n
	return r


def riders(s):
	r = 1
	d = 0
	for i in s:
		d += i
		if d > 100:
			r += 1
			d = i
	return r


def riders(stations):
	count = 1
	distance = 0
	for station in stations:
		if distance + station > 100:
			count += 1
			distance = 0
		distance += station
	return count


def riders(stations):
	(riders, distance) = (1, 0)
	for i in stations:
		distance += i
		if distance > 100:
			(riders, distance) = (riders + 1, i)
	return riders


def riders(stations):
	s = 0
	r = 1
	for (a, n) in zip(stations, stations[1:]):
		s += a
		if s + n > 100:
			r += 1
			s = 0
	return r