[Tutor] Problem

shahan khan shahankhan0 at gmail.com
Sun Aug 28 18:55:43 EDT 2016


Yes i format my code but i can't figure out this new problem

On Mon, Aug 29, 2016 at 3:20 AM, Joel Goldstick <joel.goldstick at gmail.com>
wrote:

> On Sun, Aug 28, 2016 at 10:46 AM, shahan khan <shahankhan0 at gmail.com>
> wrote:
> > Hello
> > I'm teching myself Python using MIT opencourse ware. I'm a beginner and
> > have some what knowledge of c and c++. I'm using Python version
> >
> > Here is the problem:
> > McDiophantine: Selling McNuggets
> > In mathematics, a Diophantine equation (named for Diophantus of
> Alexandria,
> > a third century Greek mathematician) is a polynomial equation where the
> > variables can only take on integer values. Although you may not realize
> it,
> > you have seen Diophantine equations before: one of the most famous
> > Diophantine equations is:
> > xn + yn= zn.
> > For n=2, there are infinitely many solutions (values for x, y and z)
> called
> > the Pythagorean triples, e.g. 32 + 42 = 52. For larger values of n,
> > Fermat’s famous “last theorem” states that there do not exist any
> positive
> > integer solutions for x, y and z that satisfy this equation. For
> centuries,
> > mathematicians have studied different Diophantine equations; besides
> > Fermat’s last theorem, some famous ones include Pell’s equation, and the
> > Erdos-Strauss conjecture. For more information on this intriguing branch
> of
> > mathematics, you may find the Wikipedia article of interest.
> > We are not certain that McDonald’s knows about Diophantine equations
> > (actually we doubt that they do), but they use them! McDonald’s sells
> > Chicken McNuggets in packages of 6, 9 or 20 McNuggets. Thus, it is
> > possible, for example, to buy exactly 15 McNuggets (with one package of 6
> > and a second package of 9), but it is not possible to buy exactly 16
> > nuggets, since no non-negative integer combination of 6’s, 9’s and 20’s
> > adds up to 16. To determine if it is possible to buy exactly n McNuggets,
> > one has to solve a Diophantine equation: find non-negative integer values
> > of a, b, and c, such that
> > 6a + 9b + 20c = n.
> > Problem 1.
> > Show that it is possible to buy exactly 50, 51, 52, 53, 54, and 55
> > McNuggets, by finding solutions to the Diophantine equation. You can
> solve
> > this in your head, using paper and pencil, or writing a program. However
> > you chose to solve this problem, list the combinations of 6, 9 and 20
> packs
> > of McNuggets you need to buy in order to get each of the exact amounts.
> > Given that it is possible to buy sets of 50, 51, 52, 53, 54 or 55
> McNuggets
> > by combinations of 6, 9 and 20 packs, show that it is possible to buy 56,
> > 57,…, 65 McNuggets. In other words, show how, given solutions for 50-55,
> > one can derive solutions for 56-65.
> > Theorem: If it is possible to buy x, x+1,…, x+5 sets of McNuggets, for
> some
> > x, then it is possible to buy any number of McNuggets >= x, given that
> > McNuggets come in 6, 9 and 20 packs.
> >
> > Here is my code:
> >  for a in range(1,10):
> > for b in range(1,5):
> > for c in range(1,5):
> > mc=(6*a)+(9*b)+(20*c)
> > if mc==50:
> > print a,b,c
> > else:
> > print a,b,c
> > a=+1
> > b=b+1
> > c=c+1
>
> Welcome to the list.
>
> You need to format your code correctly for anyone to help you.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list