Search the Community
Showing results for tags 'paper'.
-
Challenge: Create the smallest number lines of AutoIt code to create a paper, rock, scissors game in which you ask for the user's choice and generate a random result for the computer. Good luck. Note: Mat can't play in this game. Sorry! If this needs to be moved then by all means move it to an appropriate location. Thanks.
-
Created in only 2 lines. The first Console.WriteLine() is not included as it's there just to report the valid values. using System; namespace RockPaperScissorsFinal { internal class Program { private static void Main() { Console.WriteLine("(1) Rock \n(2) Paper \n(3) Scissors\nEnter your choice: "); do { // Nested ternary statements. What a pain to read , but hey it's only 2 lines ;) Also this uses what we've already learnt. string[] answers = { Console.ReadLine(), "Rock", "Paper", "Scissors", new Random().Next(1, 3).ToString() }; Console.WriteLine(answers[0] != "1" && answers[0] != "2" && answers[0] != "3" ? "Please enter a valid value next time." : "You chose {0} and the computer chose {1} with an outcome of " + (answers[0] == answers[4] ? "the same" : (answers[0] == "1" && answers[4] == "3") || (answers[0] == "2" && answers[4] == "1") || (answers[0] == "3" && answers[4] == "2") ? "winning" : "losing") + ".", answers[int.Parse(answers[0])], answers[int.Parse(answers[4])]); } while (true); } } }