I'm trying to generate permutations of digits 1-9 to filter it further. At the moment, I have got:
- Code: Select all
from itertools import permutations as perm
This works fine. It generates a long list of tuples containing permutations of the digits. I've got a few ideas that I can't implement:
a) Is it possible to output it straight into a list of integers (not tuples)?
b) Is it possible to filter out even numbers straight away. I don't need even numbers (I don't mean digits, just numbers, eg. I don't need 987654312)
I know I can do it afterwards (ie. store all of it in a variable and then play with it) but I'd like to shorten the generation time.