Project Euler # Triangular, pentagonal and hexagonal in Python
The way this was written, it was meant to steer you in the direction you did.


  Find the next triangle number that is also pentagonal and hexagonal.


You loop the triangles to find matches in the others:


for triangle in triangles:
    if triangle in pentagons and triangle in hexagons:
        yield triangle



But if you think about it, there are more triangles than pentagons and more pentagons than hexagons. And since you need to find occurences where all 3 types match, wouldn't it be better to loop the hexagons, and find a match on the others from there?

My point is: 

Don't let the way a question is asked influence the way you implement an algorithm.