how to generate all possible combinations of a 14x10 matrix containing only 1's and 0's

前端 未结 11 1008
悲&欢浪女
悲&欢浪女 2021-01-23 23:32

I\'m working on a problem and one solution would require an input of every 14x10 matrix that is possible to be made up of 1\'s and 0\'s... how can I generate these so that I can

11条回答
  •  执笔经年
    2021-01-24 00:18

    Trying this:

    import numpy
    for i in xrange(int(1e9)): a = numpy.random.random_integers(0,1,(14,10))
    

    (which is much, much, much smaller than what you require) should be enough to convince you that this is not feasible. It also shows you how to calculate one, or few, such random matrices even up to a million is pretty fast).

    EDIT: changed to xrange to "improve speed and memory requirements" :)

提交回复
热议问题