Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80379

Re:generating 2D bit array variants with specific algorythm

From Dave Angel <davea@davea.name>
Subject Re:generating 2D bit array variants with specific algorythm
Date 2014-11-07 14:34 -0500
Organization news.gmane.org
References <0e6787f9-88d6-423a-8410-7578fa83d61c@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.15573.1415388864.18130.python-list@python.org> (permalink)

Show all headers | View raw


Robert Voigtländer <r.voigtlaender@gmail.com> Wrote in message:
> Hi,
> 
> I need to generate all variants of a 2D array with variable dimension sizes which fit a specific rule. (up to 200*1000)
> 
> The rules are:
> - Values are only 0 or 1
> - the sum of each line bust be 1
> - only valid results must be generated (generating all and only returning the valid results takes to long; that's what I tried already)
> 
> So for a 2x2 array these would be the valid results:
> 
> 10
> 01
> 
> 01
> 10
> 
> 10
> 10
> 
> 01
> 01
> 
> 
> Must be possible with nested loops and a counter per line. But I don't get it.

If the matrix is m by n, then there are 2**n possibilities for
 each row. But only n of them are legal by your rules. So your
 problem is just a matter of counting in base n, all the possible
 m digit numbers.


-- 
DaveA

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

generating 2D bit array variants with specific algorythm Robert Voigtländer <r.voigtlaender@gmail.com> - 2014-11-07 07:39 -0800
  Re: generating 2D bit array variants with specific algorythm Joel Goldstick <joel.goldstick@gmail.com> - 2014-11-07 10:51 -0500
    Re: generating 2D bit array variants with specific algorythm Robert Voigtländer <r.voigtlaender@gmail.com> - 2014-11-07 08:02 -0800
      Re: generating 2D bit array variants with specific algorythm "ast" <nomail@invalid.com> - 2014-11-07 17:40 +0100
  Re: generating 2D bit array variants with specific algorythm Peter Otten <__peter__@web.de> - 2014-11-07 17:29 +0100
  Re: generating 2D bit array variants with specific algorythm "ast" <nomail@invalid.com> - 2014-11-07 17:57 +0100
    Re: generating 2D bit array variants with specific algorythm "ast" <nomail@invalid.com> - 2014-11-07 17:58 +0100
  Re:generating 2D bit array variants with specific algorythm Dave Angel <davea@davea.name> - 2014-11-07 14:34 -0500
  Re: generating 2D bit array variants with specific algorythm Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-11-07 15:41 -0500
  Re: generating 2D bit array variants with specific algorythm Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-08 10:13 +1300
    Re: generating 2D bit array variants with specific algorythm sohcahtoa82@gmail.com - 2014-11-07 17:10 -0800

csiph-web