mercredi 27 novembre 2019

How to generate 2**40 possible binary numbers with conditions

I want to generate all possible 2**N binary numbers with conditions that every array must have 20 of ones (1) like this: 00000000001111111111111111111110000000000, i found methods of generating the binary matrix like this one:

import itertools
l = itertools.product([0, 1], repeat=N)

and i tried to generate it using Numpy but i get memory errors.

So is there any other methods ?




Aucun commentaire:

Enregistrer un commentaire