Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: rules on vector sequence

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98086] Re: [mg98018] rules on vector sequence
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 29 Mar 2009 02:49:32 -0500 (EST)
  • Reply-to: hanlonr at cox.net

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


  • Prev by Date: Re: manipulate, NDSolve, Evaluate
  • Next by Date: Re: How include a online help for Package in the Documentation Center
  • Previous by thread: Re: rules on vector sequence
  • Next by thread: Re: rules on vector sequence