private static long GetDay22Part2() { var decks = GetDay22Input(); _ = CombatHelper.TryPlayGame(decks, true, out Deck winner); return(CombatHelper.GetWinnerScore(winner)); }
public void TryPlayGameTest() { var testData = new List <Tuple <IList <string>, bool, bool, Deck> >() { new Tuple <IList <string>, bool, bool, Deck>( new List <string>() { "Player 1:", "9", "2", "6", "3", "1", "", "Player 2:", "5", "8", "4", "7", "10" }, false, true, new Deck("Player 2", new List <int>() { 3, 2, 10, 6, 8, 5, 9, 4, 7, 1 })), new Tuple <IList <string>, bool, bool, Deck>( new List <string>() { "Player 1:", "9", "2", "6", "3", "1", "", "Player 2:", "5", "8", "4", "7", "10" }, true, true, new Deck("Player 2", new List <int>() { 7, 5, 6, 2, 4, 1, 10, 8, 9, 3 })) }; foreach (var testExample in testData) { var decks = DeckHelper.ParseInputLines(testExample.Item1); var isSuccessful = CombatHelper.TryPlayGame(decks, testExample.Item2, out Deck winner); Assert.Equal(testExample.Item3, isSuccessful); Assert.NotNull(winner); Assert.Equal(testExample.Item4.PlayerName, winner.PlayerName); Assert.Equal(testExample.Item4.SpaceCards, winner.SpaceCards); } }