Created
March 30, 2017 10:21
-
-
Save NimJ/45ccfb541439e882988a079cd3e8b195 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Class a: | |
| def cow_bull(self): | |
| import random | |
| cowbull = [0,0] | |
| count = 1 | |
| x = random.sample([1,2,3,4,5,6,7,8,9,0],4) | |
| y = list(input('input 4 digits seperated by spaces \n ')) | |
| while x != y: | |
| for i in range(3): | |
| if y[i] in x: | |
| if y[i] == x[i]: | |
| cowbull[0] += 1 | |
| else: | |
| cowbull[1] += 1 | |
| print '{0} cows and {1} bulls'.format(cowbull[0], cowbull[1]) | |
| y = list(input('input 4 digits seperated by comma \n ')) | |
| cowbull = [0, 0] | |
| count += 1 | |
| print 'you won with {0} guesses'.format(count) | |
| if __name__ == '__main__': | |
| a = A() | |
| a.cow_bull() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment