Skip to content

Commit e920501

Browse files
KumarUniverseKumarUniverse
KumarUniverse
authored and
KumarUniverse
committed
Removed helper function and modified print stmt
1 parent c902c36 commit e920501

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

project_euler/problem_301/sol1.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,6 @@
3333
"""
3434

3535

36-
def x(n: int, n2: int, n3: int) -> int:
37-
"""
38-
Returns:
39-
- zero if, with perfect strategy, the player about to
40-
move will eventually lose; or
41-
- non-zero if, with perfect strategy, the player about
42-
to move will eventually win.
43-
44-
>>> x(1, 2, 3)
45-
0
46-
>>> x(3, 6, 9)
47-
12
48-
>>> x(8, 16, 24)
49-
0
50-
>>> x(11, 22, 33)
51-
60
52-
>>> x(1000, 2000, 3000)
53-
3968
54-
"""
55-
return n ^ n2 ^ n3
56-
57-
5836
def solution(n: int = 2 ** 30) -> int:
5937
"""
6038
For a given integer n <= 2^30, returns how many Nim games are lost.
@@ -65,11 +43,11 @@ def solution(n: int = 2 ** 30) -> int:
6543
"""
6644
loss_count = 0
6745
for i in range(1, n + 1):
68-
if x(i, 2 * i, 3 * i) == 0:
46+
if (i^(2*i)^(3*i)) == 0:
6947
loss_count += 1
7048

7149
return loss_count
7250

7351

7452
if __name__ == "__main__":
75-
print(solution())
53+
print(f"{solution() = }")

0 commit comments

Comments
 (0)