public void CaveSystem_system1_ReadsCorrectly() { var caveSys = new CaveSystem("system1.txt"); for (int i = 1; i <= 30; i++) { int[] ThisArray = caveSys.GetConnectedArray(i); switch (i) { case 1: CollectionAssert.AreEqual(ThisArray, new int[] { 0, 0, 2, 7, 0, 0 }); break; case 2: CollectionAssert.AreEqual(ThisArray, new int[] { 0, 3, 0, 0, 7, 1 }); break; default: break; } } //removing duplicates and making connections double sided }
private void Prob2Start() { var info = GetInfo("depth: 10647\ntarget: 7,770"); Console.WriteLine("Running in thread"); var system = new CaveSystem(info); //system.DumpMap(); system.Start(); Console.WriteLine("Result: " + system.currentMinTimeToTarget); }
void Start() { cave = FindObjectOfType <CaveSystem>(); cave.Initialize(transform); cave.OnReset(); frame = new Frame(transform); spline = new CatmullRom(splineResolution); controlPoints = new Queue <Vector3>(controlPointCount); controlPoints.Enqueue(frame.origin); maxIndex = splineResolution * 3 - 1; }
private string SharedSolution(List <string> inputs, Dictionary <string, string> variables, bool extended) { int pathCount = 0; CaveSystem caveSystem = new CaveSystem(extended); foreach (string input in inputs) { string[] split = input.Split('-', StringSplitOptions.RemoveEmptyEntries).ToArray(); caveSystem.AddConnectedCaves(split); } caveSystem.Caves.ForEach(c => c.Connections.Remove(caveSystem.Start)); caveSystem.End.Connections.Clear(); caveSystem.Traverse(ref pathCount); return(pathCount.ToString()); }
public static void Task2() { cave = new CaveSystem[(int)target.X + 11, (int)target.Y + 11]; for (int y = 0; y <= target.Y + 10; y++) { for (int x = 0; x <= target.X + 10; x++) { int gi = GeologicIndex(x, y); int el = (gi + depth) % 20183; cave[x, y] = new CaveSystem(gi, el, x, y); } } ShortestPath(); }
public static void Task1() { cave = new CaveSystem[(int)target.X + 1, (int)target.Y + 1]; int risklvl = 0; for (int y = 0; y <= target.Y; y++) { for (int x = 0; x <= target.X; x++) { int gi = GeologicIndex(x, y); int el = (gi + depth) % 20183; cave[x, y] = new CaveSystem(gi, el); risklvl += cave[x, y].Type; } } Console.WriteLine(risklvl); }
public async Task Test_ProductOfLargestBasins_Test(string file, int?expectedValue = null) { // Arrange var textLines = await File.ReadAllLinesAsync(file); var puzzleInput = textLines .Where(line => !string.IsNullOrWhiteSpace(line)) .ToList(); var caveSystem = new CaveSystem(puzzleInput); // Act var calculation = caveSystem.ProductOfLargestBasins(); // Assert if (expectedValue.HasValue) { Assert.AreEqual(expectedValue, calculation); } Debug.WriteLine(calculation); }
public void ReadFileTest() { var caveSys = new CaveSystem("allConnected.txt"); Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); // or Trace.Listeners.Add(new ConsoleTraceListener()); Trace.WriteLine("Hello World"); //CollectionAssert.AreEqual(caveSys.GetConnectedArray(1), new int[] { 25, 26, 2, 7, 6, 30 }); //CollectionAssert.AreEqual(caveSys.GetConnectedArray(2), new int[] { 26, 3, 9, 8, 7, 1 }); StreamWriter debug = new StreamWriter("readInValues.txt"); for (int i = 1; i <= 30; i++) { int[] ThisArray = caveSys.GetAdjacentArray(i); debug.WriteLine("Cave Num: " + i.ToString() + String.Join(",", ThisArray)); switch (i) { case 1: CollectionAssert.AreEqual(ThisArray, new int[] { 25, 26, 2, 7, 6, 30 }); break; case 2: CollectionAssert.AreEqual(ThisArray, new int[] { 26, 3, 9, 8, 7, 1 }); break; case 3: CollectionAssert.AreEqual(ThisArray, new int[] { 27, 28, 4, 9, 2, 26 }); break; default: break; } } debug.Close(); }
public void ReadFileTest() { var caveSys = new CaveSystem("allConnected.txt"); //CollectionAssert.AreEqual(caveSys.GetConnectedArray(1), new int[] { 25, 26, 2, 7, 6, 30 }); //CollectionAssert.AreEqual(caveSys.GetConnectedArray(2), new int[] { 26, 3, 9, 8, 7, 1 }); StreamWriter debug = new StreamWriter("readInValues.txt"); for (int i = 1; i <= 30; i++) { int[] ThisArray = caveSys.GetAdjacentArray(i); debug.WriteLine("Cave Num: " + i.ToString() + String.Join(",", ThisArray)); switch (i) { case 1: CollectionAssert.AreEqual(ThisArray, new int[] { 25, 26, 2, 7, 6, 30 }); break; case 2: CollectionAssert.AreEqual(ThisArray, new int[] { 26, 3, 9, 8, 7, 1 }); break; case 3: CollectionAssert.AreEqual(ThisArray, new int[] { 27, 28, 4, 9, 2, 26 }); break; default: break; } } //removing duplicates and making connections double sided debug.Close(); }
public void Write_File_AllConnect_Test() { var caveSys = new CaveSystem(); caveSys.WriteFile("test.txt"); }
public void TestRandom() { var caveSys = new CaveSystem('r'); caveSys.WriteFile("randCave.txt"); }