Example #1
0
        public void GetBusIdWithLowestWaitTimeTest()
        {
            // For example, suppose you have the following notes:
            // 939
            // 7,13,x,x,59,x,31,19
            // Here, the earliest timestamp you could depart is 939, and the
            // bus IDs in service are 7, 13, 59, 31, and 19.
            // The earliest bus you could take is bus ID 59. It doesn't depart
            // until timestamp 944, so you would need to wait 944 - 939 = 5
            // minutes before it departs. Multiplying the bus ID by the number
            // of minutes you'd need to wait gives 295.
            var testData = new List <Tuple <string, string, Tuple <int, int> > >()
            {
                new Tuple <string, string, Tuple <int, int> >(
                    "939",
                    "7,13,x,x,59,x,31,19",
                    new Tuple <int, int>(59, 5))
            };

            foreach (var testExample in testData)
            {
                var busData = BusHelper.ParseInputLines(testExample.Item1, testExample.Item2);
                var actual  = BusHelper.GetBusIdWithLowestWaitTime(busData);
                Assert.Equal(testExample.Item3, actual);
            }
        }