Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Table for FindInstance solutions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114575] Table for FindInstance solutions
  • From: MH <matthewhoek at gmail.com>
  • Date: Wed, 8 Dec 2010 06:41:31 -0500 (EST)

Hello.  I'm trying to display in a table solutions to the equation 6S
+ 9N + 20T = D, where D is an integer allowed to go from 1 to 100.  I
can use FindInstance to find solutions with no problems.  What'd I'd
really like, though, is a table with four columns: one column each for
D, S, N, and T.  The following code gets me close to what I want, but
every entry in the last three columns is the same.  And, every entry
gives the value for S, N, and T, instead of just the appropriate S or
N or T value.  For example, when D = 71, that row reads

71  {S -> 7, N -> 1, T -> 1}  {S -> 7, N -> 1, T -> 1}  {S -> 7, N ->
1, T -> 1}.

I can interpret the correct result (7 sixes, 1 nine, and 1 twenty),
but I'd like the column to read

71  7  1  1

How can I change that?  Incidentally, this problem is from a current
issue of Delta Airlines' Sky Magazine.  The problem asks about a baker
who sells donuts in boxes of 6, 9, and 20.  What's the largest number
of donuts you CANNOT purchase?  I have the solution; I'd just like it
to look a little bit nicer.  :-)

Thanks!

MH

=====
TableForm[
 Table[
  {D,
   FindInstance[
    6 S + 9 N + 20 T == D && S >= 0 && N >= 0 && T >= 0, {S, N, T},
    Integers],
   FindInstance[
    6 S + 9 N + 20 T == D && S >= 0 && N >= 0 && T >= 0, {S, N, T},
    Integers],
   FindInstance[
    6 S + 9 N + 20 T == D && S >= 0 && N >= 0 && T >= 0, {S, N, T},
    Integers]
   },
  {D, 1, 20, 1}],
 TableHeadings -> {None, {"TOTAL", "BOXES OF 6", "BOXES OF 9",
    "BOXES OF 20"}},
 TableAlignments -> {Center},
 TableSpacing -> {1, 3}
 ]
=====


  • Prev by Date: Re: CMake module for Mathematica
  • Next by Date: Re: Replacement Rule with Sqrt in denominator
  • Previous by thread: Re: 8.0 Control Systems ToDiscreteTimeModel[]
  • Next by thread: Re: Table for FindInstance solutions