Mark-Jason Dominus writes about taking a too-sophisticated approach to a puzzler about generating triangular numbers with many divisors, ending up with a program that produced the answer in a minute and a half when someone else's much shorter code took longer to compute but was much easier to write. But it took me only five minutes or so (less than it took to write up this blog entry, anyway) to write an even more sophisticated version of Dominus' idea, that produces the correct answer instantly even running in Python. The trick: I had a generator for already-factored numbers prewritten in PADS and could just plug it in. And of course taking advantage of the analysis Mark wrote up for his solution kept my own thinking time low...here's the code, slightly cleaned up from my original version:

from Eratosthenes import FactoredIntegers

def triphi():
    y,py = 0,0
    for x,fx in FactoredIntegers():
        px = 1
        for p,a in fx.items():
            if p == 2: a -= 1
            px *= a+1
        yield (x*y)//2,px*py
        y,py = x,px

for t,pt in triphi():
    if pt >= 500:
        print t,pt
        break