Esempio n. 1
0
        public void Output3Test()
        {
            Tube tube = new Tube(100000, 101, 51);

            Assert.AreEqual(114101, tube.GetTotalDistanceOfMillimeters());

            tube = new Tube(100000, 101, 51);
            tube = new Tube("marbles.txt");
            Assert.AreEqual(114101, tube.GetTotalDistanceOfMillimeters());
        }
Esempio n. 2
0
        public void MarbleFillTest()
        {
            Tube tube = new Tube(expectedLength, expectedMarbles, expectedCheck);

            Assert.AreEqual(expectedMarbles, tube.Marbles.Count);

            tube = new Tube(expectedLength, expectedMarbles, expectedCheck);
            tube = new Tube("marbles.txt");
            Assert.AreEqual(expectedMarbles, tube.Marbles.Count);
        }
Esempio n. 3
0
        public void OutputExpectedTest()
        {
            Tube tube = new Tube(expectedLength, expectedMarbles, expectedCheck);

            Assert.AreEqual(expectedTotalDistance, tube.GetTotalDistanceOfMillimeters());

            tube = new Tube(expectedLength, expectedMarbles, expectedCheck);
            tube = new Tube("marbles.txt");
            Assert.AreEqual(expectedTotalDistance, tube.GetTotalDistanceOfMillimeters());

            tube = new Tube("marbles.txt");
            Assert.AreEqual(expectedTotalDistance, tube.GetTotalDistanceOfMillimeters());
        }
Esempio n. 4
0
        public void InitialDirectionsTest()
        {
            Tube tube = new Tube(expectedLength, expectedMarbles, expectedCheck);

            Assert.AreEqual(false, tube.Marbles[0].MovingWest);
            Assert.AreEqual(true, tube.Marbles[1].MovingWest);
            Assert.AreEqual(true, tube.Marbles[2].MovingWest);

            tube = new Tube(expectedLength, expectedMarbles, expectedCheck);
            tube = new Tube("marbles.txt");
            Assert.AreEqual(false, tube.Marbles[0].MovingWest);
            Assert.AreEqual(true, tube.Marbles[1].MovingWest);
            Assert.AreEqual(true, tube.Marbles[2].MovingWest);
        }
Esempio n. 5
0
        public void InitialPositionsTest()
        {
            Tube tube = new Tube(expectedLength, expectedMarbles, expectedCheck);

            Assert.AreEqual((UInt64)127, tube.Marbles[0].PositionMillimeters);
            Assert.AreEqual((UInt64)579, tube.Marbles[1].PositionMillimeters);
            Assert.AreEqual((UInt64)772, tube.Marbles[2].PositionMillimeters);

            tube = new Tube(expectedLength, expectedMarbles, expectedCheck);
            tube = new Tube("marbles.txt");
            Assert.AreEqual((UInt64)127, tube.Marbles[0].PositionMillimeters);
            Assert.AreEqual((UInt64)579, tube.Marbles[1].PositionMillimeters);
            Assert.AreEqual((UInt64)772, tube.Marbles[2].PositionMillimeters);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            bool argsNumericOk = args.Length == 3;
            bool argsFileOk    = args.Length == 1;

            UInt64 L = 0;
            int    N = 0;
            int    j = 0;


            if (argsNumericOk && !UInt64.TryParse(args[0], out L))
            {
                argsNumericOk = false;
            }
            if (argsNumericOk && !int.TryParse(args[1], out N))
            {
                argsNumericOk = false;
            }
            if (argsNumericOk && !int.TryParse(args[2], out j))
            {
                argsNumericOk = false;
            }

            Tube tube = null;

            if (argsNumericOk)
            {
                tube = new Tube(L, N, j);
            }
            else if (argsFileOk)
            {
                tube = new Tube(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, args[0]));
            }

            if (!argsNumericOk && !argsFileOk)
            {
                Console.WriteLine("Usage: " + System.AppDomain.CurrentDomain.FriendlyName + " L N j.  See https://projecteuler.net/problem=653");
                Console.WriteLine("Usage: " + System.AppDomain.CurrentDomain.FriendlyName + " filename.txt");
                return;
            }

            Console.WriteLine(tube?.GetTotalDistanceOfMillimeters());
        }