Hacker News new | past | comments | ask | show | jobs | submit login

I actually tried, and my generator version ended up less readable than yours. I was not expecting this, but for such an algo the way you write it gives this impression the data flow from one end to the other, which reads better than splitting it in several functions including nested blocks.

The only drawbacks I can see:

- if you want to debug that with PDB, you are out of luck.

- anybody not wanting to spend the time understanding what it does will freak out.

Unrelated, but you can do:

def get_ranges(i): return product(*(range(1, 27) for _ in range(i)))

To replaced stuff like:

    for th in range(1, 27)
    for o in range(1, 27)
    for r in range(1, 27)
With:

    for th, o, r in get_ranges(3)
But again, no sure it makes things better. Shorter yes, but the benefit of your version is that each step is very clear.

I still have no idea what's this code is for though :)




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: