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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder1.news.weretis.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'nested': 0.07; 'counting': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'wrote': 0.14; 'dimension': 0.16; 'loops': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'rule.': 0.16; 'rules.': 0.16; 'subject:array': 0.16; 'subject:bit': 0.16; 'variants': 0.16; 'variable': 0.18; 'fit': 0.20; 'rules': 0.22; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'tried': 0.27; 'array': 0.29; 'robert': 0.30; 'are:': 0.33; 'problem': 0.35; 'subject:with': 0.35; 'but': 0.35; 'there': 0.35; 'returning': 0.36; 'possible': 0.36; 'hi,': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'matter': 0.61; 'sum': 0.64; 'results': 0.69; 'legal': 0.71; 'received:myvzw.com': 0.84; 'subject::': 0.85
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dave Angel <davea@davea.name>
Subject Re:generating 2D bit array variants with specific algorythm
Date Fri, 7 Nov 2014 14:34:11 -0500 (EST)
Organization news.gmane.org
References <0e6787f9-88d6-423a-8410-7578fa83d61c@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host 184.sub-70-208-162.myvzw.com
X-Newsreader PiaoHong.Usenet.Client.VIP:1.63
X-Archive encrypt
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15573.1415388864.18130.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1415388864 news.xs4all.nl 2935 [2001:888:2000:d::a6]:57667
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:80379

Show key headers only | 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