The Pony Express (missing rider)
Description:
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.
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.
Missing rider
In this version of the Kata a rider may go missing. In practice, this could be for a number of reasons - a lame horse, an accidental fall, foul play...
After some time, the rider's absence would be noticed at the next station, so the next designated rider from there would have to back-track the mail route to look for his missing colleague. The missing rider is then safely escorted back to the station he last came from, and the mail bags are handed to his rescuer (or another substitute rider if necessary).
stationX
is the number (2..N) of the station where the rider's absence was noticed.
Notes
- Each rider travels as far as he can, but never more than 100 miles.
Example
GIven
stations = [43, 23, 40, 13]
stationX = 4
So
S1
... ... 43 ... ... S2
... ... 23 ... ... S3
... ... 40 ... ... S4
... ... 13 ... ... S5
- Rider 1 gets as far as Station S3
- Rider 2 (at station S3) takes mail bags from Rider 1
- Rider 2 never arrives at station S4
- Rider 3 goes back to find what happened to Rider 2
- Rider 2 and Rider 3 return together back to Station S3
- Rider 3 takes mail bags from Rider 2
- Rider 3 completes the journey to Station S5
Answer: 3 riders
Good Luck.
DM.
See also
- The Pony Express
- The Pony Express (missing rider)
Similar Kata:
Stats:
Created | Jun 12, 2018 |
Published | Jun 13, 2018 |
Warriors Trained | 503 |
Total Skips | 4 |
Total Code Submissions | 3058 |
Total Times Completed | 146 |
Java Completions | 34 |
JavaScript Completions | 45 |
Python Completions | 66 |
Ruby Completions | 12 |
C# Completions | 11 |
Total Stars | 16 |
% of votes with a positive feedback rating | 88% of 54 |
Total "Very Satisfied" Votes | 42 |
Total "Somewhat Satisfied" Votes | 11 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 4 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |