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()); }
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); }
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()); }
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); }
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); }
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()); }