Re: A puzzle for Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg42415] Re: [mg42393] A puzzle for Mathematica
- From: Dr Bob <majort at cox-internet.com>
- Date: Sat, 5 Jul 2003 03:11:00 -0400 (EDT)
- References: <200307040533.BAA10473@smc.vnet.net>
- Reply-to: majort at cox-internet.com
- Sender: owner-wri-mathgroup at wolfram.com
Here are six solutions for n=3, m=1. eqns[(n_Integer)?Positive, (m_Integer)?Positive] := Join[Join[Table[Sum[a[i, k], {k, 1, n}] == m, {i, 1, n}], Table[Sum[a[k, i], {k, 1, n}] == m, {i, 1, n}]], Flatten[Table[0 <= a[i, j] <= 1, {i, 1, n}, {j, 1, n}]]] vars[(n_Integer)?Positive] := Flatten[matrix[n]] matrix[(n_Integer)?Positive] := matrix[n] = Table[a[i, j], {i, 1, n}, {j, 1, n}] n = 3; m = 1; soln = Last@Maximize[{0, eqns[n, m]}, vars[n]] (r = matrix[n] /. soln) // MatrixForm (Outer[r[[#1, #2]] &, Permutations@Range@n, Permutations@Range@n, 1] /. soln // Flatten[#, 1] & // Union) MatrixForm /@ % Bobby On Fri, 4 Jul 2003 01:33:11 -0400 (EDT), Souvik Banerjee <s- banerjee at nwu.edu> wrote: > Hello, > > How many n x n binary matrices (that is, whose elements are either 0 or > 1) > are possible such that each row and each column sum exactly to m <= n > (both > m and n are positive integers)? > > How do you solve this in Mathematica? A method for generating would be > good > to although not necessary. > > Thanks, > > -Souvik > > > -- majort at cox-internet.com Bobby R. Treat
- References:
- A puzzle for Mathematica
- From: "Souvik Banerjee" <s-banerjee@nwu.edu>
- A puzzle for Mathematica