Skip to content

Commit 183db31

Browse files
committed
Refactored code
1 parent eddaa5b commit 183db31

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

python/power.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
'''2 players play a game. A number is given as input. If the number is a power of 2(i.e, 2^1, 2^2 .. 2^64),
2-
then divide the number by 2 and pass the number to the other player. Else, if the number is not a power
3-
of 2, then subtract the number with its nearest 2 power number and pass the number to the other player.
4-
PlayerA always starts the game. The player who gets to value 1(one) is the winner. Output the name of
5-
the winner, i.e, 'PlayerA' or 'PlayerB'
1+
# Asked by - Delta X
2+
3+
# 2 players play a game. A number is given as input. If the number is a power of 2(i.e, 2^1, 2^2 .. 2^64),
4+
# then divide the number by 2 and pass the number to the other player. Else, if the number is not a power
5+
# of 2, then subtract the number with its nearest 2 power number and pass the number to the other player.
6+
# PlayerA always starts the game. The player who gets to value 1(one) is the winner. Output the name of
7+
# the winner, i.e, 'PlayerA' or 'PlayerB'
68

7-
Ex:
8-
n = 10
9-
Output: PlayerB
9+
# Ex:
10+
# n = 10
11+
# Output: PlayerB
1012

11-
n = 12
12-
Output = PlayerA'''
13+
# n = 12
14+
# Output = PlayerA
1315

1416
import math
1517

0 commit comments

Comments
 (0)