Commit 0e4ff66b authored by Nayuki Minase's avatar Nayuki Minase

P14, P24, P30, P34, P35, P36, P40, P69, P70, P71, P72, P92, P135, P150, P173,...

P14, P24, P30, P34, P35, P36, P40, P69, P70, P71, P72, P92, P135, P150, P173, P174, P182: Added logic to use xrange in Python 2 for speed.
parent 55140150
......@@ -6,6 +6,10 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import sys
if sys.version_info.major == 2:
range = xrange
def compute():
ans = max((i for i in range(1, 1000000)), key=collatz_chain_length)
......
......@@ -6,7 +6,9 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import itertools
import itertools, sys
if sys.version_info.major == 2:
range = xrange
def compute():
......
......@@ -6,6 +6,10 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import sys
if sys.version_info.major == 2:
range = xrange
def compute():
# As stated in the problem, 1 = 1^5 is excluded.
......
......@@ -6,7 +6,9 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import eulerlib
import eulerlib, sys
if sys.version_info.major == 2:
range = xrange
def compute():
......
......@@ -6,7 +6,9 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import eulerlib
import eulerlib, sys
if sys.version_info.major == 2:
range = xrange
isprime = eulerlib.list_primality(999999)
......
......@@ -6,6 +6,10 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import sys
if sys.version_info.major == 2:
range = xrange
def compute():
ans = sum(i for i in range(1000000) if is_decimal_binary_palindrome(i))
......
......@@ -6,6 +6,10 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import sys
if sys.version_info.major == 2:
range = xrange
def compute():
s = "".join(str(i) for i in range(1, 1000000))
......
......@@ -6,6 +6,10 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import sys
if sys.version_info.major == 2:
range = xrange
def compute():
totients = list(range(1000001))
......
......@@ -6,6 +6,10 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import sys
if sys.version_info.major == 2:
range = xrange
def compute():
totients = list(range(10000000))
......
......@@ -6,6 +6,10 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import sys
if sys.version_info.major == 2:
range = xrange
def compute():
maxnumer = 0
......
......@@ -6,7 +6,9 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import itertools
import itertools, sys
if sys.version_info.major == 2:
range = xrange
def compute():
......
......@@ -6,6 +6,10 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import sys
if sys.version_info.major == 2:
range = xrange
def compute():
ans = 0
......
......@@ -6,6 +6,10 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import sys
if sys.version_info.major == 2:
range = xrange # Very important to let the inner loop terminate early
# Let x = m, y = m - k, z = m - 2k (this is an arithmetic sequence).
# By tedious but straightforward algebra, x^2 - y^2 - z^2 = (m - k)(5k - m).
......
......@@ -6,6 +6,10 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import sys
if sys.version_info.major == 2:
range = xrange
def compute():
# Generate the triangle
......
......@@ -6,6 +6,10 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import sys
if sys.version_info.major == 2:
range = xrange # Very important to let the inner loop terminate early
def compute():
TILES = 10**6
......
......@@ -6,6 +6,10 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import sys
if sys.version_info.major == 2:
range = xrange # Very important to let the inner loop terminate early
def compute():
SIZE_LIMIT = 1000000
......
......@@ -6,7 +6,9 @@
# https://github.com/nayuki/Project-Euler-solutions
#
import eulerlib
import eulerlib, sys
if sys.version_info.major == 2:
range = xrange
def compute():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment