Simplify code by dropping support for legacy Python (#1143)

* Simplify code by dropping support for legacy Python

* sort() --> sorted()
This commit is contained in:
Christian Clauss
2019-08-19 15:37:49 +02:00
committed by GitHub
parent 32aa7ff081
commit 47a9ea2b0b
145 changed files with 367 additions and 976 deletions

View File

@ -17,14 +17,8 @@ It is not until n = 23, that a value exceeds one-million: 23C10 = 1144066.
How many, not necessarily distinct, values of nCr, for 1 ≤ n ≤ 100, are greater
than one-million?
"""
from __future__ import print_function
from math import factorial
try:
xrange # Python 2
except NameError:
xrange = range # Python 3
def combinations(n, r):
return factorial(n) / (factorial(r) * factorial(n - r))
@ -39,8 +33,8 @@ def solution():
"""
total = 0
for i in xrange(1, 101):
for j in xrange(1, i + 1):
for i in range(1, 101):
for j in range(1, i + 1):
if combinations(i, j) > 1e6:
total += 1
return total