Re: rules on vector sequence
- To: mathgroup at smc.vnet.net
- Subject: [mg98087] Re: [mg98018] rules on vector sequence
- From: Filippo Miatto <sottosupremo at gmail.com>
- Date: Sun, 29 Mar 2009 02:49:44 -0500 (EST)
- References: <11367732.52414.1238245886953.JavaMail.hanlonr@127.0.0.1>
Thank you Bob, that is faster than what i did. And if i'll need to tweak the rules now i know how it works! Filippo On Mar 28, 2009, at 2:11 PM, Bob Hanlon wrote: > a = Range[-2, 2]; > > n = 4; > > Select[Tuples[ > Table[a, {n}]], (Total[#] == > 0) && > ((n - Count[#, 0] == 2) || (n - Count[#, 0] == 4)) &] > > > > Bob Hanlon > > > On Sat, Mar 28, 2009 at 9:11 AM , Filippo Miatto wrote: > >> Dear all, >> I need to generate all the vectors, of a given length N, that have >> these three properties: >> >> 1- the entries have to be among -2,-1,0,1,2 >> 2- the sum of all the entries has to be 0 >> 3- only two or four of the entries can be different from 0 >> >> do you have any suggestions on how i can do that? i tried something >> but without success.. expecially i don't know how to implement the >> third rule.. >> thank you in advance! >> Filippo