Sinisterly
Rock, Paper, Scissors - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Coding (https://sinister.li/Forum-Coding--71)
+--- Thread: Rock, Paper, Scissors (/Thread-Rock-Paper-Scissors)



Rock, Paper, Scissors - Dijkstra - 09-10-2015

The first spot in IO goes to the person who:
 makes a Rock, Paper, Scissors program in 2 or less lines, preferably in Python.

Conditions
1) You may not put any semicolons (";") in your code.
2) The program is to ask the user "Rock, paper, scissors?".
3) The program must output whether the lost or won.
4) You can not import the program from another file. >:-(

Have fun!


RE: [IO] Rock, Paper, Scissors - Sophisticated - 09-10-2015

Why Python.

Worst coding language ever.

smthng like
return guess == 'rock' or guess == 'paper' or guess == 'scissors'


RE: [IO] Rock, Paper, Scissors - Dijkstra - 09-10-2015

(09-10-2015, 04:03 AM)Die Wrote: Why Python.

Worst coding language ever.

smthng like
return guess == 'rock' or guess == 'paper' or guess == 'scissors'

Python would be the easiest to 1-2 line it. C;
You must grab the users input and output win or loss too.

A hint would be to look at Rock, Paper, Scissors as a game of chance.

Also, for those who don't know.
You can do if statements like this...

Code:
x = 3 y = 4 if x == 3 else 5 if x == 2 else 10



RE: [IO] Rock, Paper, Scissors - Sophisticated - 09-10-2015

(09-10-2015, 04:07 AM)Dijkstra Wrote:
(09-10-2015, 04:03 AM)Die Wrote: Why Python.

Worst coding language ever.

smthng like
return guess == 'rock' or guess == 'paper' or guess == 'scissors'

Python would be the easiest to 1-2 line it. C;
You must grab the users input and output win or loss too.

A hint would be to look at Rock, Paper, Scissors as a game of chance.

if cpu == 'rock' and p1 == 'rock':
if cpu == p1:
print('meh)


RE: [IO] Rock, Paper, Scissors - Jeteroll - 09-10-2015

(09-10-2015, 04:03 AM)Die Wrote: Why Python.

Worst coding language ever.

smthng like
   return guess == 'rock' or guess == 'paper' or guess == 'scissors'

I disagree. Python, although it has its inconsistencies, is very simple, beautiful, and concise. It takes a lot of the things that other languages make you specifically implement and automates them to remove unnecessary, repetitive work. Python remains one of my favorite languages because it's very easy to quickly deploy a script or application from scratch.


RE: [IO] Rock, Paper, Scissors - Dijkstra - 09-14-2015

A huge hint would be that you have a 1/3 chance of winning the game.

1 - You win,
2 - A tie,
3 - You lose


RE: Rock, Paper, Scissors - Rick_ - 11-11-2015

Why has nobody done this yet?
Python:
Code:
a = input("Rock, Paper, Scissors?") print("You win") if a == "Rock" else print("You lose") if a == "Paper" else print("You tie")

Computers always go scissors, it's a fact.

Here is a second version which works a bit differently (Very shitty psudo random generator based off of variable hex addresses)
Code:
a,b = input("Rock, Paper, Scissors? "),["Paper","Rock","Scissors","Paper"] print("You win, the computer went:",b[b.index(a)+1]) if int(list(str(id(a)))[len(list(str(id(a))))-1]) in [0,3,2,6] else print("You tied, the computer went:",a,"as well!") if int(list(str(id(a)))[len(list(str(id(a))))-1]) in [1,9,7] else print("You lost! The computer went: Scissors") if a == "Paper" else print("You lost! The computer went:",b[b.index(a)-1])

Both of these obviously assume that you input your choice perfectly, capitals and all. No error handler.