Skip to content

Commit 18605a1

Browse files
Merge pull request #115 from kathirvelrajmohan/passingGame
Passing Game Commit [Hacktober Fest 2023]
2 parents 5355975 + 3a7d765 commit 18605a1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

python/ballPassingGame.py

+21
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)