Skip to content

Commit 3a7d765

Browse files
Passing Game Commit
1 parent 52d62ac commit 3a7d765

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

python/ballPassingGame.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
''' Ball Passing Game '''
2+
def passing(n, t):
3+
check = 1
4+
val = 1
5+
6+
for i in range(t):
7+
if check == 1:
8+
if val + 1 == n:
9+
check = -1
10+
val += 1
11+
else:
12+
if val - 1 == 1:
13+
check = 1
14+
val -= 1
15+
16+
return val
17+
18+
n = int(input("Enter the Number of members: "))
19+
t = int(input("Enter the seconds: "))
20+
result = passing(n, t)
21+
print("The person holding the pillow after", t, "seconds is:", result)

0 commit comments

Comments
 (0)