public static void PartOne() { string input = InputHelper.GetInputFromFile("22"); string[] lines = input.Split(Environment.NewLine); StackShuffler stack = new StackShuffler(); stack.Start(10007); foreach (string line in lines) { if (line.StartsWith("deal with increment ")) { stack.DealWithIncrement(int.Parse(line.Split(' ')[3])); } if (line.StartsWith("cut ")) { stack.CutNCards(int.Parse(line.Split(' ')[1])); } if (line == "deal into new stack") { stack.DealIntoNewStack(); } } Console.WriteLine("Position of card 2019 : " + stack.GetStack().IndexOf(2019)); }
public void CutNCards_Negative_Should_Put_Size_Minus_N_Cards_At_The_End() { StackShuffler shufflerTested = new StackShuffler(); shufflerTested.Start(10); shufflerTested.CutNCards(-4); var stack = shufflerTested.GetStack(); stack.Count.Should().Be(10); stack.Should().ContainInOrder(new List <int> { 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 }); }
public void Chaining_Calls_Should_Yield_Correct_Result() { StackShuffler shufflerTested = new StackShuffler(); shufflerTested.Start(10); shufflerTested.DealIntoNewStack(); shufflerTested.CutNCards(-2); shufflerTested.DealWithIncrement(7); shufflerTested.CutNCards(8); shufflerTested.CutNCards(-4); shufflerTested.DealWithIncrement(7); shufflerTested.CutNCards(3); shufflerTested.DealWithIncrement(9); shufflerTested.DealWithIncrement(3); shufflerTested.CutNCards(-1); var stack = shufflerTested.GetStack(); stack.Count.Should().Be(10); stack.Should().ContainInOrder(new List <int> { 9, 2, 5, 8, 1, 4, 7, 0, 3, 6 }); }
public void CutNCards_Should_Put_N_Cards_At_The_End() { StackShuffler shufflerTested = new StackShuffler(); shufflerTested.Start(10); shufflerTested.CutNCards(3); var stack = shufflerTested.GetStack(); stack.Count.Should().Be(10); stack.Should().ContainInOrder(new List <int> { 3, 4, 5, 6, 7, 8, 9, 0, 1, 2 }); }