private static string CalculateResult(string intputFilename)
        {
            CarTrafficData data = new CarTrafficData(intputFilename);

            int roundTime = 1;
            bool anyCarTraveling = true;
            while (anyCarTraveling)
            {
                anyCarTraveling = false;
                foreach (CarTrafficData.CarData car in data.cars)
                {
                    if (car.current == car.end)
                        continue;

                    anyCarTraveling = true;
                    if (roundTime < car.startingTime)
                        continue;

                    ++car.traveldTime;

                    bool isBlocked = CheckedIsBlocked(car, data);

                    MoveCar(car, isBlocked);
                }

                UpdateCarPositions(data);
                roundTime++;
                //DisplayMovement(data);

                Console.WriteLine();
            }

            StringBuilder result = CreateOutputString(data);
            return result.ToString();
        }
        private static bool CheckIsPositionBlocked(CarTrafficData data, int checkPosition)
        {
            foreach (CarTrafficData.CarData subCars in data.cars)
            {
                if (subCars.hasReachedDestination || !subCars.hasStarted)
                    continue;

                if (IsBlocking(checkPosition, subCars))
                    return true;
            }

            return false;
        }
        private static bool CheckedIsBlocked(CarTrafficData.CarData car, CarTrafficData data)
        {
            if (car.hasStarted)
            {
                int checkPosition = car.current + 1;
                return CheckIsPositionBlocked(data, checkPosition);
            }

            bool isBlocking = CheckIsPositionBlocked(data, car.current);
            isBlocking = isBlocking || CheckIsPositionBlocked(data, car.current - 1);

            return isBlocking;
        }
        private static StringBuilder CreateOutputString(CarTrafficData data)
        {
            StringBuilder result = new StringBuilder();
            bool first = true;

            foreach (CarTrafficData.CarData car in data.cars)
            {
                if (first)
                {
                    result.Append((car.startingTime).ToString());
                    first = false;
                }
                else
                {
                    result.Append("," + (car.startingTime).ToString());
                }
            }
            return result;
        }
        private static void DisplayMovement(CarTrafficData data)
        {
            for (int i = 0; i < 100; ++i)
            {
                int currentCar = -1;
                foreach (CarTrafficData.CarData car in data.cars)
                {
                    if (car.current == i && car.hasStarted && car.hasReachedDestination == false)
                    {
                        Debug.Assert(currentCar == -1);
                        currentCar = car.id;
                    }
                }

                if (currentCar != -1)
                {
                    if (currentCar < 10)
                    {
                        Console.Write("0" + currentCar.ToString());
                    }
                    else
                    {
                        Console.Write(currentCar);
                    }
                }
                else
                {
                    Console.Write("  ");
                }
            }
        }
        private void PrintData(CarTrafficData data)
        {
            Console.WriteLine(string.Format("Num segments: {0}", data.numSegments));
            Console.WriteLine(string.Format("Num segments: {0}", data.numCars));

            foreach (CarTrafficData.CarData car in data.cars)
            {
                Console.WriteLine("Start: {0} ; End: {1}", car.start, car.end);
            }
        }
        private static void UpdateCarPositions(CarTrafficData data)
        {
            foreach (CarTrafficData.CarData car in data.cars)
            {
                car.hasReachedDestination = car.current == car.end;

                if (car.shouldStartNextFrame)
                    car.hasStarted = true;

                if (car.hasStarted)
                    car.current = car.next;
            }
        }
        private static List<int> RetreiveCheckPoints(CarTrafficData.CarData car)
        {
            List<int> checkPositions = new List<int>();
            if (car.hasStarted)
            {
                checkPositions.Add(car.current + 1);
            }
            else
            {
                checkPositions.Add(car.current);
                checkPositions.Add(car.current - 1);
            }

            return checkPositions;
        }
 private static void MoveCar(CarTrafficData.CarData car, bool isBlocked)
 {
     if (isBlocked == false)
     {
         if (car.hasStarted == false)
         {
             car.shouldStartNextFrame = true;
             car.next = car.current;
         }
         else
         {
             car.next = car.current + 1;
         }
     }
     else
     {
         car.next = car.current;
     }
 }
        private static bool IsBlocking(List<int> checkPositions, CarTrafficData.CarData subCars)
        {
            bool isBlocked = false;
            foreach (int checkPosition in checkPositions)
            {
                isBlocked = subCars.current == checkPosition;
                if (isBlocked)
                    break;
            }

            return isBlocked;
        }
 private static bool IsBlocking(int checkPosition, CarTrafficData.CarData subCars)
 {
     return subCars.current == checkPosition;
 }