Sets
def NotDumbRockPaperScissors(player1, player2): rock = {"paper"} paper = {"scissors"} scissors = {"rock"} # set variable names to lowercase if player1.lower() in eval(player2.lower()): return "Player 1 wins" elif player2.lower() in eval(player1.lower()): return "Player 2 wins" # converted the input args into lowercase for more consistent comparisons else: return "Draw"
def dumbRockPaperScissors(player1, player2):Rock = {"Paper"}Paper = {"Scissors"}Scissors = {"Rock"}if player1 in eval(player2):- def NotDumbRockPaperScissors(player1, player2):
- rock = {"paper"}
- paper = {"scissors"}
- scissors = {"rock"}
- # set variable names to lowercase
- if player1.lower() in eval(player2.lower()):
- return "Player 1 wins"
elif player2 in eval(player1):- elif player2.lower() in eval(player1.lower()):
- return "Player 2 wins"
- # converted the input args into lowercase for more consistent comparisons
- else:
- return "Draw"
import codewars_test as test from solution import NotDumbRockPaperScissors @test.describe("NotDumbRockPaperScissors") def fixed_tests(): @test.it('Basic Test Cases') def basic_test_cases(): test.assert_equals(NotDumbRockPaperScissors('Rock', 'Rock'),'Draw') test.assert_equals(NotDumbRockPaperScissors('Rock', 'Paper'),'Player 2 wins') test.assert_equals(NotDumbRockPaperScissors('Paper', 'Rock'),'Player 1 wins') test.assert_equals(NotDumbRockPaperScissors('Paper', 'Paper'),'Draw') test.assert_equals(NotDumbRockPaperScissors('Rock', 'Scissors'),'Player 1 wins') test.assert_equals(NotDumbRockPaperScissors('Paper', 'Scissors'),'Player 2 wins') test.assert_equals(NotDumbRockPaperScissors('Scissors', 'Rock'),'Player 2 wins') test.assert_equals(NotDumbRockPaperScissors('Scissors', 'Paper'),'Player 1 wins') test.assert_equals(NotDumbRockPaperScissors('Scissors', 'Scissors'),'Draw')
- import codewars_test as test
from solution import dumbRockPaperScissors- from solution import NotDumbRockPaperScissors
@test.describe("dumbRockPaperScissors")- @test.describe("NotDumbRockPaperScissors")
- def fixed_tests():
- @test.it('Basic Test Cases')
- def basic_test_cases():
test.assert_equals(dumbRockPaperScissors('Rock', 'Rock'),'Draw')test.assert_equals(dumbRockPaperScissors('Rock', 'Paper'),'Player 2 wins')test.assert_equals(dumbRockPaperScissors('Paper', 'Rock'),'Player 1 wins')test.assert_equals(dumbRockPaperScissors('Paper', 'Paper'),'Draw')test.assert_equals(dumbRockPaperScissors('Rock', 'Scissors'),'Player 1 wins')test.assert_equals(dumbRockPaperScissors('Paper', 'Scissors'),'Player 2 wins')test.assert_equals(dumbRockPaperScissors('Scissors', 'Rock'),'Player 2 wins')test.assert_equals(dumbRockPaperScissors('Scissors', 'Paper'),'Player 1 wins')test.assert_equals(dumbRockPaperScissors('Scissors', 'Scissors'),'Draw')- test.assert_equals(NotDumbRockPaperScissors('Rock', 'Rock'),'Draw')
- test.assert_equals(NotDumbRockPaperScissors('Rock', 'Paper'),'Player 2 wins')
- test.assert_equals(NotDumbRockPaperScissors('Paper', 'Rock'),'Player 1 wins')
- test.assert_equals(NotDumbRockPaperScissors('Paper', 'Paper'),'Draw')
- test.assert_equals(NotDumbRockPaperScissors('Rock', 'Scissors'),'Player 1 wins')
- test.assert_equals(NotDumbRockPaperScissors('Paper', 'Scissors'),'Player 2 wins')
- test.assert_equals(NotDumbRockPaperScissors('Scissors', 'Rock'),'Player 2 wins')
- test.assert_equals(NotDumbRockPaperScissors('Scissors', 'Paper'),'Player 1 wins')
- test.assert_equals(NotDumbRockPaperScissors('Scissors', 'Scissors'),'Draw')
I removed the unnecessary import ('re' library, originally) and got the job done with the python built in functions only.