Here is my code:

- Code: Select all
`from time import sleep`

from time import clock

import math

def getDivisors(x):

divList = []

y = 1

while y <= math.sqrt(x):

if x % y == 0:

divList.append(y)

if x/y != y:

divList.append(int(x / y))

y += 1

divList.remove(x)

return divList

def sumDiv(num):

div = getDivisors(num)

add = 0

for x in div:

add+=x

return add

start = clock()

abundantNums = []

for x in range(1,28123):

if sumDiv(x) > x:

print x,sumDiv(x)

sleep(0)

abundantNums.append(x)

print "abundant nums created",len(abundantNums)

all_sums = set()

last = False

for y in range(len(abundantNums)):

for z in range(y+1,len(abundantNums)):

temp = abundantNums[y]+abundantNums[z]

if temp < 28123 and temp not in all_sums:

all_sums.add(temp)

percent = int((float(y)/(len(abundantNums)-1)*100))

if percent%10 != 0: last = True

if percent%10 == 0 and last is True:

print str(percent)+"%"

last = False

not_sum = 0

lstart = 0

all_nums = [x for x in range(1,28123)]

for z in all_sums:

all_nums.remove(z)

print "ANSWER: "+str(sum(all_nums))

print clock()-start

#ANSWER:

#TIME: