This is my 1st month to any coding in life and my first question over internet as well so kindly bare with my mistakes if any.
I have a list of 52 US states like:
States=[‘AL’,’AK’,’AR’, …..,’WY’]
LEN(states)= 52.
I am trying to get all combinations possible with all pairs i.e. 2^N combinations where N=52.
I tired with itertools.Combinations with below code example available on line
import itertools
stuff = [‘A’,’B’,’C’,’D’]
for L in range(len(stuff) + 1):
for subset in:
itertools.combinations(stuff, L):
print(subset)
This is taking very long execution time and never ends before my system crashed.
On new laptop I tried using powerset,and all possible solutions I got on below page as well:
Get all possible (2^N) combinations of a list’s elements, of any length
But got memory issue.
Can anyone has any idea how to overcome this issue? Kindly guide me.
Abhinav Mishra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.