Skip to content

Instantly share code, notes, and snippets.

@RikkiGibson
Last active October 27, 2018 18:15
Show Gist options
  • Save RikkiGibson/f0771f6cecb9b769493f9c3f28f0c4c4 to your computer and use it in GitHub Desktop.
Save RikkiGibson/f0771f6cecb9b769493f9c3f28f0c4c4 to your computer and use it in GitHub Desktop.
private static void ValidateGoogleSchedule(List<GoogleRouteSchedule> routeSchedules)
{
foreach (GoogleRouteSchedule routeSchedule in routeSchedules)
{
foreach (GoogleDaySchedule routeDaySchedule in routeSchedule.Days)
{
var stopSchedules = routeDaySchedule.StopSchedules;
var pairs = stopSchedules.Take(stopSchedules.Count - 1).Zip(stopSchedules.Skip(1), (fst, snd) => (fst, snd));
foreach (var (fst, snd) in pairs)
{
Debug.Assert(fst.Times.Count == snd.Times.Count);
for (var i = 0; i < fst.Times.Count; i++)
{
if (fst.Times[0] > snd.Times[0])
{
Console.WriteLine($"Time travel violation for {routeSchedule.RouteNo}. {fst.Name} at {fst.Times[i]} occurs after and {snd.Name} at {snd.Times[i]}");
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment