Permalink
Browse files

Rock, Paper, Scissors, Lizard, Spock kata

Just first iteration, without git history
  • Loading branch information...
figarocorso committed Dec 11, 2015
1 parent 0acc016 commit cc68b301b716f26d4429eb1ae79ea93dda6fcee2
Showing with 57 additions and 0 deletions.
  1. +20 −0 pptls/pptls.py
  2. +37 −0 pptls/pptls_test.py
View
@@ -0,0 +1,20 @@
class PPTLS:
def check_winner(self, first_choice, second_choice):
first_choice = first_choice.lower()
second_choice = second_choice.lower()
winner = {
'rock': ['lizard', 'scissors'],
'scissors': ['paper', 'lizard'],
'paper': ['rock', 'spock'],
'spock': ['scissors', 'rock'],
'lizard': ['paper', 'spock'],
}
if second_choice == first_choice:
return 0
if second_choice in winner[first_choice]:
return 1
return 2
View
@@ -0,0 +1,37 @@
import unittest
from pptls import PPTLS
class TestPPTLS(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_scissors(self):
pptls = PPTLS()
self.assertEqual(1, pptls.check_winner("scissors", "paper"))
self.assertEqual(2, pptls.check_winner("lizard", "rock"))
self.assertEqual(2, pptls.check_winner("scissors", "rock"))
self.assertEqual(2, pptls.check_winner("scissors", "spock"))
self.assertEqual(2, pptls.check_winner("rock", "Spock"))
self.assertEqual(2, pptls.check_winner("spock", "lizard"))
self.assertEqual(2, pptls.check_winner("paper", "lizard"))
self.assertEqual(2, pptls.check_winner("rock", "paper"))
self.assertEqual(2, pptls.check_winner("spock", "paper"))
self.assertEqual(2, pptls.check_winner("paper", "scissors"))
self.assertEqual(2, pptls.check_winner("lizard", "scissors"))
def test_tie(self):
pptls = PPTLS()
self.assertEqual(0, pptls.check_winner("spock", "spock"))
def test_capital_letters(self):
pptls = PPTLS()
self.assertEqual(2, pptls.check_winner("scissors", "Spock"))
self.assertEqual(2, pptls.check_winner("Scissors", "Spock"))
if __name__ == "__main__":
unittest.main()

1 comment on commit cc68b30

@figarocorso

This comment has been minimized.

Show comment
Hide comment
@figarocorso

figarocorso Dec 11, 2015

Owner

Short (less than one hour) kata done with @hoscarh and @cokeperez at Frogtek.

Owner

figarocorso commented on cc68b30 Dec 11, 2015

Short (less than one hour) kata done with @hoscarh and @cokeperez at Frogtek.

Please sign in to comment.