Created
February 2, 2016 17:14
-
-
Save spoorcc/00dd4b27905c38e1f8a3 to your computer and use it in GitHub Desktop.
In progress solution to euler problem 351
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
def number_of_occlusions(N): | |
all_points = [x+1 for x in range(N)] | |
occluded_points = [0 for x in range(N)] | |
number_of_occlusions = 0 | |
for i in range(1,N/2+1): | |
delta = i | |
j = i + delta | |
while j < N: | |
all_points[j] -= all_points[i] | |
occluded_points[j] += all_points[i] | |
number_of_occlusions += all_points[i] | |
j = j + delta | |
print(occluded_points) | |
return number_of_occlusions | |
def calculate(rings): | |
''' Calculates problem https://projecteuler.net/problem=351 ''' | |
return( 6 * (number_of_occlusions(rings)) ) | |
for h in [5, 10, 1000]: | |
print(calculate(h)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment