public void AddBusLine(string lineName) { if (!BusLines.Contains(lineName)) { this.BusLines.Add(lineName); } }
public async Task <List <Bus> > GetBusScheduleAsync(IOptions <AppSettings> appSettings) { var busUrl = CreateBusUrl(appSettings); BusLines busLines = await GetBusesAsync(busUrl); return(CreateBusList(busLines)); }
public void Example6() { List <string> IdStrings = new List <string> { "67", "7", "x", "59", "61" }; BusLines buslines = new BusLines(); long result = buslines.FindSequence2(IdStrings); Assert.AreEqual(1261476, result); }
public void Example3() { List <string> IdStrings = new List <string> { "17", "x", "13", "19" }; BusLines buslines = new BusLines(); long result = buslines.FindSequence2(IdStrings); Assert.AreEqual(3417, result); }
public void Example8() { List <string> IdStrings = new List <string> { "7", "13", "x", "x", "59", "x", "31", "19" }; BusLines buslines = new BusLines(); long result = buslines.FindSequence2(IdStrings); Assert.AreEqual(1068781, result); }
public void Example7() { List <string> IdStrings = new List <string> { "1789", "37", "47", "1889" }; BusLines buslines = new BusLines(); long result = buslines.FindSequence2(IdStrings); Assert.AreEqual(1202161486, result); }
public static long Problem2() { List <string> input = File.ReadAllLines("Data/Day13.txt").ToList(); List <string> ids = input[1].Split(",").ToList(); BusLines busslines = new BusLines(); long result = busslines.FindSequence2(ids); Console.WriteLine(result); return(result); }
public void Example2() { int earliest = 939; List <string> IdStrings = new List <string> { "7", "13", "x", "x", "59", "x", "31", "19" }; BusLines buslines = new BusLines(); long result = buslines.ParseAndGetAnswer(earliest, IdStrings); Assert.AreEqual(295, result); }
public static long Problem1() { List <string> input = File.ReadAllLines("Data/Day13.txt").ToList(); int earliest = input[0].ToInt(); List <string> ids = input[1].Split(",").ToList(); BusLines busslines = new BusLines(); long result = busslines.ParseAndGetAnswer(earliest, ids); Console.WriteLine(result); return(result); }
public void Example1() { int earliest = 939; List <int> Ids = new List <int> { 7, 13, 59, 31, 19 }; BusLines buslines = new BusLines(); int Id = buslines.FindEarliestDepartureId(earliest, Ids); Assert.AreEqual(59, Id); long earliestDeparture = buslines.FindEarliestDeparture(earliest, Id); Assert.AreEqual(944, earliestDeparture); }
private List <Bus> CreateBusList(BusLines busLines) { List <Bus> buses = new List <Bus>(); if (busLines.m1.Any()) { buses = busLines.m1; if (busLines.m3?.Count() > 0) { buses.AddRange(busLines.m3); } buses = buses.GroupBy(x => new { x.EstimatedDepartureTime, x.BusName }).Select(x => x.First()).OrderBy(b => b.EstimatedDepartureTime).ToList(); } return(buses); }