SHARE
TWEET

CardGame

imprisoned_mindz Oct 23rd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace CardGame
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> playerOne = Console.ReadLine()
  12.              .Split(' ')
  13.              .Select(int.Parse)
  14.              .ToList();
  15.  
  16.             List<int> playerTwo = Console.ReadLine()
  17.              .Split(' ')
  18.              .Select(int.Parse)
  19.              .ToList();
  20.  
  21.             while (true)
  22.             {
  23.                 if (playerOne[0] > playerTwo[0])
  24.                 {
  25.                     playerOne.Add(playerOne[0]);
  26.                     playerOne.Add(playerTwo[0]);
  27.                 }
  28.                 else if (playerOne[0] < playerTwo[0])
  29.                 {
  30.                     playerTwo.Add(playerOne[0]);
  31.                     playerTwo.Add(playerTwo[0]);
  32.                 }
  33.                 playerOne.Remove(playerOne[0]);
  34.                 playerTwo.Remove(playerTwo[0]);
  35.  
  36.                 if (playerOne.Count == 0)
  37.                 {
  38.                     Console.WriteLine("Second player wins! Sum: {0}", playerTwo.Sum());
  39.                     break;
  40.                 }
  41.                 else if(playerTwo.Count == 0)
  42.                 {
  43.                     Console.WriteLine("First player wins! Sum: {0}", playerOne.Sum());
  44.                     break;
  45.                 }
  46.             }
  47.         }
  48.     }
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top