Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Re: Re: integer solution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62134] Re: [mg62088] Re: Re: [mg61988] integer solution
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sat, 12 Nov 2005 03:31:58 -0500 (EST)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

My second example should have been written more efficiently as 

Select[Flatten[Table[{s,d,t,10-s-d-t},
          {s,7},{d,8-s},{t,9-s-d}],2],
      (#.{1,1,1,1}==10&&#.{6,3,2,1}==30)&]//Timing//First

0.004094 Second


Bob Hanlon

> 
> From: Bob Hanlon <hanlonr at cox.net>
To: mathgroup at smc.vnet.net
> Date: 2005/11/11 Fri AM 02:51:51 EST
> Subject: [mg62134] [mg62088] Re: Re: [mg61988] integer solution
> 
> Some timings for various solutions:
> 
> {s,d,t,q}/.{Reduce[{
>           s+d+t+q==10,
>           6s+3d+2t+q==30,
>           s>0,d>0,t>0,q>0},
>         {s,d},Integers]//ToRules}//Timing//First
> 
> 0.023069 Second
> 
> Select[Flatten[Table[{s,d,t,q},
>           {s,7},{d,8-s},{t,9-s-d},{q,10-s-d-t}],3],
>       (#.{1,1,1,1}==10&&#.{6,3,2,1}==30)&]//Timing//First
> 
> 0.007569 Second
> 
> Needs["DiscreteMath`Combinatorica`"];
> 
> Select[Compositions[6,4]+1,
>       (#.{6,3,2,1}==30)&]//Timing//First
> 
> 0.013004 Second
> 
> 
> Bob Hanlon
> 
> > 
> > From: Bob Hanlon <hanlonr at cox.net>
To: mathgroup at smc.vnet.net
> > Date: 2005/11/08 Tue AM 06:38:15 EST
> > To: bd satish <bdsatish at gmail.com>, <mathgroup at smc.vnet.net>
> > Subject: [mg62134] [mg62088] Re: [mg61988] integer solution
> > 
> > {s,d,t,q}/.{Reduce[{
> >           s+d+t+q==10,
> >           6s+3d+2t+q==30,
> >           s>0,d>0,t>0,q>0},
> >         {s,d},Integers]//ToRules}
> > 
> > {{1, 7, 1, 1}, {2, 3, 4, 1}, {2, 4, 2, 2}, {3, 1, 3, 3}, {3, 2, 1, 4}}
> > 
> > 
> > Bob Hanlon
> > 
> > > 
> > > From: bd satish <bdsatish at gmail.com>
To: mathgroup at smc.vnet.net
> > > Date: 2005/11/08 Tue AM 03:41:30 EST
> > > Subject: [mg62134] [mg62088] [mg61988] integer solution
> > > 
> > > 
> > >  I want to find the integral solutions of the following two equations:
> > >    s + d + t+q =10 ; # two equations
> > >   6s + 3d + 2t + q = 30 ; # 4 unknowns
> > >   I want only those solutions for which
> > >   s>0 d>0 t>0 q>0
> > > 
> > > 
> > 
> 
> 


  • Prev by Date: Re: ((a&&b)||c)==((a||c)&&(b||c))
  • Next by Date: Re: Tilting at Windmills?
  • Previous by thread: Re: Re: integer solution
  • Next by thread: Re: Window names in Mathematica under Linux/KDE