We have talked several times about Big O, but it stills difficult sometimes to find a suitable function for what we are looking for. I thought about using this post for puting the codes we need to improve with a Big O, and the other users can help us to make them better. Looking at our and the rest of users' problems we can really improve our skills at using Big O.

I will start puting the code I am working at now (Problem 12). Notice that you should not continue reading if you have not completed this problem (in order to avoid code-spoilers):

- Code: Select all
`triangulos = []`

for x in xrange(1,9999):

y = sum(i for i in xrange(1,x+1))

triangulos.append(y)

lista = []

factores = []

for x in triangulos:

for i in xrange(1,x+1):

if x%i == 0:

factores.append(i)

if len(factores) >= 500:

result = x,factores

del(factores)

factores = []

lista.append(result)

del(result)

break

elif len(factores) < 500:

del(factores)

factores = []

I put the whole code because as a beginner I am at Big O, I do not really know where should I improve it.

According to other posts, I tried something like using sqrt(), and although it run really fast, it did not give me a suitable result. So I would be pleased if you can help me to "open my mind" to new ways of using Big O.

Thank you very much.