Skip to content

Commit 5a7bac7

Browse files
committed
P14, P30, P34, P35, P36, P40, P44, P50, P71, P92, P135, P150, P173, P174, P179, P182, P211, P216, P347, P357, P549, eulerlib: Removed detection of Python 2 and usage of xrange().
Readme: Updated text.
1 parent 93df3b1 commit 5a7bac7

23 files changed

+11
-77
lines changed

Readme.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ Every solved problem has a program written in Java and usually Python. Some solu
77

88
All problems from #1 to #100 have a Java and Python program, and problems #1 to #50 have a Mathematica program. This package contains at least 200 solutions in Java, at least 200 in Python, at least 125 in Mathematica, and at least 95 in Haskell.
99

10-
Java solutions require JDK 7+. Python solutions are tested to work on CPython 2.7.10 and 3.4.3. Mathematica solutions are tested to work on Mathematica 5.1.
10+
Java solutions require JDK 7+. Python solutions are tested to work on CPython 3.4.3. Mathematica solutions are tested to work on Mathematica 5.1.
1111

1212
Home page with background info, table of solutions, benchmark timings, and more: [https://www.nayuki.io/page/project-euler-solutions](https://www.nayuki.io/page/project-euler-solutions)
1313

1414
----
1515

16-
Copyright © 2019 Project Nayuki. All rights reserved. No warranty.
16+
Copyright © 2020 Project Nayuki. All rights reserved. No warranty.
1717

1818
This code is provided for reference only. You may republish any of this code verbatim with author and URL info intact.
1919

python/eulerlib.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import array, math, sys
10-
if sys.version_info.major == 2:
11-
range = xrange
9+
import array, math
1210

1311

1412
# Returns the number of 1's in the binary representation of

python/p014.py

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#
88

99
import eulerlib, sys
10-
if sys.version_info.major == 2:
11-
range = xrange
1210

1311

1412
# We compute the Collatz chain length for every integer in the range according to the iteration rule.

python/p030.py

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import sys
10-
if sys.version_info.major == 2:
11-
range = xrange
12-
139

1410
def compute():
1511
# As stated in the problem, 1 = 1^5 is excluded.

python/p034.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import math, sys
10-
if sys.version_info.major == 2:
11-
range = xrange
9+
import math
1210

1311

1412
def compute():

python/p035.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import eulerlib, sys
10-
if sys.version_info.major == 2:
11-
range = xrange
9+
import eulerlib
1210

1311

1412
def compute():

python/p036.py

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import sys
10-
if sys.version_info.major == 2:
11-
range = xrange
12-
139

1410
def compute():
1511
ans = sum(i for i in range(1000000) if is_decimal_binary_palindrome(i))

python/p040.py

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import sys
10-
if sys.version_info.major == 2:
11-
range = xrange
12-
139

1410
def compute():
1511
s = "".join(str(i) for i in range(1, 1000000))

python/p044.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import itertools, sys
10-
if sys.version_info.major == 2:
11-
range = xrange
9+
import itertools
1210

1311

1412
def compute():

python/p050.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import eulerlib, sys
10-
if sys.version_info.major == 2:
11-
range = xrange
9+
import eulerlib
1210

1311

1412
def compute():

python/p071.py

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import sys
10-
if sys.version_info.major == 2:
11-
range = xrange
12-
139

1410
# We consider each (integer) denominator d from 1 to 1000000 by brute force.
1511
# For a given d, what is the largest integer n such that n/d < 3/7?

python/p092.py

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import sys
10-
if sys.version_info.major == 2:
11-
range = xrange
12-
139

1410
def compute():
1511
ans = sum(1

python/p135.py

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import sys
10-
if sys.version_info.major == 2:
11-
range = xrange # Very important to let the inner loop terminate early
12-
139

1410
# Let x = m, y = m - k, z = m - 2k (this is an arithmetic sequence).
1511
# By tedious but straightforward algebra, x^2 - y^2 - z^2 = (m - k)(5k - m).

python/p150.py

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import sys
10-
if sys.version_info.major == 2:
11-
range = xrange
12-
139

1410
def compute():
1511
# Generate the triangle

python/p173.py

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import sys
10-
if sys.version_info.major == 2:
11-
range = xrange # Very important to let the inner loop terminate early
12-
139

1410
def compute():
1511
TILES = 10**6

python/p174.py

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import sys
10-
if sys.version_info.major == 2:
11-
range = xrange # Very important to let the inner loop terminate early
12-
139

1410
def compute():
1511
SIZE_LIMIT = 1000000

python/p179.py

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import sys
10-
if sys.version_info.major == 2:
11-
range = xrange
12-
139

1410
def compute():
1511
divisors = [2] * (10**7 + 1) # Invalid for indexes 0 and 1

python/p182.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import fractions, sys
10-
if sys.version_info.major == 2:
11-
range = xrange
9+
import fractions
1210

1311

1412
def compute():

python/p211.py

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#
88

99
import array, eulerlib, sys
10-
if sys.version_info.major == 2:
11-
range = xrange
1210

1311

1412
def compute():

python/p216.py

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import sys
10-
if sys.version_info.major == 2:
11-
range = xrange
12-
139

1410
# As per the problem statement, define t(n) = 2n^2 - 1 and assume that always n > 1.
1511
# Hence t(n) >= 7, and the sequence is strictly increasing (with no repeats).

python/p347.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import eulerlib, sys
10-
if sys.version_info.major == 2:
11-
range = xrange
9+
import eulerlib
1210

1311

1412
def compute():

python/p357.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import eulerlib, sys
10-
if sys.version_info.major == 2:
11-
range = xrange
9+
import eulerlib
1210

1311

1412
# From the problem statement, we are given the search range of 1 <= n <= 10^8.

python/p549.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
# https://github.com/nayuki/Project-Euler-solutions
77
#
88

9-
import itertools, sys
10-
if sys.version_info.major == 2:
11-
range = xrange
9+
import itertools
1210

1311

1412
# For any n >= 2, how do we compute s(n) = m, where m is the smallest integer such that m! is divisible by n?

0 commit comments

Comments
 (0)