Skip to content

Commit 2540456

Browse files
Merge branch 'master' into keshav
2 parents 6585a84 + 1b5252d commit 2540456

File tree

2 files changed

+103
-11
lines changed

2 files changed

+103
-11
lines changed

FORKED_FOR_TSHIRT/kj.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
# In[1]:
5+
6+
7+
def win(p,total):
8+
print(total)
9+
if (total[0]==total[1] and total[0]==total[2] and total[0]==p) or (total[3]==total[4] and total[3]==total[5] and total[3]==p) or (total[6]==total[7] and total[6]==total[8] and total[6]==p) or (total[0]==total[4] and total[0]==total[7] and total[0]==p) or (total[4]==total[8] and total[4]==total[2] and total[4]==p):
10+
return True
11+
else:
12+
return False
13+
14+
15+
# In[2]:
16+
17+
18+
def grid(total):
19+
print("{}|{}|{}".format(total[0],total[1],total[2]))
20+
print("{}|{}|{}".format(total[3],total[4],total[5]))
21+
print("{}|{}|{}".format(total[6],total[7],total[8]))
22+
#grid()
23+
24+
25+
# In[3]:
26+
27+
28+
def main_game():
29+
player2 = "l"
30+
player1= input("enter your symbol- X/0--> ")
31+
if player1 == "X":
32+
player2 = "0"
33+
elif player1== "0":
34+
player2 = "X"
35+
else:
36+
player1= input("enter your symbol- X/0--> ")
37+
print("player1 = " + player1 + " player2 = " + player2)
38+
#game here
39+
40+
no_winner = True
41+
total = [1,2,3,4,5,6,7,8,9]
42+
grid(total)
43+
while no_winner:
44+
45+
total[int(input("player1 -> enter position "))-1] = player1
46+
grid(total)
47+
if win(player1,total):
48+
print("player1 won")
49+
status =False
50+
break
51+
total[int(input("player2 -> enter position "))-1] = player2
52+
grid(total)
53+
if win(player2,total):
54+
print("player1 won")
55+
status =False
56+
break
57+
58+
59+
# In[4]:
60+
61+
62+
def ask_replay():
63+
reply = input("do you want to play again - y/n")
64+
if reply == "y":
65+
print("thanks for playing again")
66+
play()
67+
else:
68+
print(" quitting the game")
69+
70+
71+
# In[ ]:
72+
73+
74+
def play():
75+
76+
main_game()
77+
ask_replay()
78+
79+
80+
81+
# In[ ]:
82+
83+
84+
play()
85+
86+
87+
# In[ ]:
88+
89+
90+
91+
92+
93+
# In[ ]:
94+
95+
96+
97+
98+
99+
# In[ ]:
100+
101+
102+
103+

README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,6 @@
33
<details open>
44
<summary>1. Codechef</summary>
55
<br>
6-
7-
<details open>
8-
<summary>July 2020Long Challenge</summary>
9-
<br>
10-
Problems name | link
11-
_________________________________________|_________________________________________
12-
[Chef and Card Game] | (https://github.com/keshavsingh4522/Python/blob/master/Codechef/July%202020/Chef%20and%20Card%20Game.py)
13-
[Chef and Strings] | (https://github.com/keshavsingh4522/Python/blob/master/Codechef/July%202020/Chef%20and%20Strings.py)
14-
[Summery] | (https://github.com/keshavsingh4522/Python/blob/master/Codechef/July%202020/JULY_2020.ipynb)
15-
</details>
16-
176
<details>
187
<summary>June 2020Long Challenge</summary>
198
<br>

0 commit comments

Comments
 (0)