7 kyu
Airport itinerary
273 of 524antenor
Description:
Travel itinerary
When you travel around the world you pass though different airports.
TRN -> FCO -> JFK
And then return back to home
JFK - TRN
In order to propose the unique list of airports that your trip uses we have to create an itinerary
feature that can compress the list of airports including only the list of unique in/out combination.
For example, a trip with:
[TRN-FCO] [FCO-JFK] [JFK-TRN]
Should be represented as:
TRN-FCO-JFK-TRN
That is the unique list of airport steps.
Now in our database we save the travel as a list of objects with in/out properties and you will receive that list always sorted in the right way.
[
{in: "TRN", out: "FCO"},
{in: "FCO", out: "JFK"},
{in: "JFK", out: "FCO"}
]
Now we have to create a helper function itinerary
for JS that extract the unique airport list:
travel = itinerary([
{in: "TRN", out: "FCO"},
{in: "FCO", out: "JFK"},
{in: "JFK", out: "FCO"}
]); // TRN-FCO-JFK-FCO
Or a helper class Route
for C#/C++:
public class Route
{
public string In;
public string Out;
}
Strings
Fundamentals
Similar Kata:
Stats:
Created | Aug 7, 2016 |
Published | Aug 7, 2016 |
Warriors Trained | 1027 |
Total Skips | 77 |
Total Code Submissions | 1657 |
Total Times Completed | 524 |
JavaScript Completions | 273 |
C# Completions | 74 |
C++ Completions | 144 |
Elixir Completions | 53 |
Total Stars | 15 |
% of votes with a positive feedback rating | 87% of 139 |
Total "Very Satisfied" Votes | 110 |
Total "Somewhat Satisfied" Votes | 22 |
Total "Not Satisfied" Votes | 7 |
Total Rank Assessments | 8 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |