Adopted new convention from template
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Created on 01 Jan 2018
|
||||
|
||||
@@ -9,9 +9,10 @@ Solution for problem 12 of Project Euler
|
||||
https://projecteuler.net/problem=12
|
||||
"""
|
||||
|
||||
import itertools
|
||||
from itertools import count
|
||||
from math import floor, sqrt
|
||||
|
||||
from utils import timeit
|
||||
from math import sqrt, floor
|
||||
|
||||
|
||||
# Returns the number of integers in the range [1, n] that divide n.
|
||||
@@ -23,8 +24,7 @@ def num_divisors(n):
|
||||
divs.append(i)
|
||||
if end**2 == n:
|
||||
divs.pop()
|
||||
return 2*len(divs)
|
||||
|
||||
return 2 * len(divs)
|
||||
|
||||
|
||||
@timeit("Problem 12")
|
||||
@@ -54,7 +54,7 @@ def compute():
|
||||
"""
|
||||
|
||||
triangle = 0
|
||||
for i in itertools.count(1):
|
||||
for i in count(1):
|
||||
# This is the ith triangle number, i.e. num = 1 + 2 + ... + i =
|
||||
# = i*(i+1)/2
|
||||
triangle += i
|
||||
@@ -63,5 +63,4 @@ def compute():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
print(f"Result for Problem 12: {compute()}")
|
||||
print(f"Result for Problem 12 is {compute()}")
|
||||
|
||||
Reference in New Issue
Block a user