public override object Task1() { (Queue <int> P1, Queue <int> P2) = ParseInput(); while (P1.Count != 0 && P2.Count != 0) { int p1card = P1.Dequeue(); int p2card = P2.Dequeue(); if (p1card > p2card) { P1.Enqueue(p1card); P1.Enqueue(p2card); } else { P2.Enqueue(p2card); P2.Enqueue(p1card); } } return(TallyScore(P1.Count == 0 ? P2 : P1)); }
public void Battle() { while (P1.Any() && P2.Any()) { RoundsPlayed++; var c1 = P1.Dequeue(); var c2 = P2.Dequeue(); if (c1 > c2) { P1.Enqueue(c1); P1.Enqueue(c2); } else { P2.Enqueue(c2); P2.Enqueue(c1); } } P1Score = CalculateScore(P1); P2Score = CalculateScore(P2); }