On 08/17/2010 11:44 PM, Baba wrote:
On Aug 16, 6:28 pm, cbr...@cbrownsystems.com
cbr...@cbrownsystems.com wrote:
First, suppose d = gcd(x, y, z); then for some x', y', z' we have that
x = d*x', y = d*y', z = d*z'; and so for any a, b, c:
could you explain the notation?
what is
On Aug 17, 2:44 pm, Baba raoul...@gmail.com wrote:
On Aug 16, 6:28 pm, cbr...@cbrownsystems.com
cbr...@cbrownsystems.com wrote:
First, suppose d = gcd(x, y, z); then for some x', y', z' we have that
x = d*x', y = d*y', z = d*z'; and so for any a, b, c:
could you explain the notation?
Hi Chas
Thanks for that and i agree on your last remark :)
re the number of required consecutive passes required:
The number of required consecutive passes is equal to the smallest
number because after that you can get any amount of nuggets by just
adding the smallest nugget pack to some other
On Aug 18, 10:52 am, Baba raoul...@gmail.com wrote:
Hi Chas
Thanks for that and i agree on your last remark :)
re the number of required consecutive passes required:
The number of required consecutive passes is equal to the smallest
number because after that you can get any amount of
On 8/18/2010 1:38 PM, cbr...@cbrownsystems.com wrote:
To go the other way, if d = 1, then there exists integers (not
neccessarily positive) such that
a*x + b*y + c*z = 1
That fact is non-trivial, although the proof isn't *too* hard [1]. I
found it interesting to demonstrate the simpler
On Aug 18, 11:50 am, John Posner jjpos...@optimum.net wrote:
On 8/18/2010 1:38 PM, cbr...@cbrownsystems.com wrote:
To go the other way, if d = 1, then there exists integers (not
neccessarily positive) such that
a*x + b*y + c*z = 1
That fact is non-trivial, although the proof isn't *too*
Paul Rubin no.em...@nospam.invalid writes:
Baba raoul...@gmail.com writes:
exercise: given that packs of McNuggets can only be bought in 6, 9 or
20 packs, write an exhaustive search to find the largest number of
McNuggets that cannot be bought in exact quantity.
Is that a homework problem?
On Aug 16, 6:28 pm, cbr...@cbrownsystems.com
cbr...@cbrownsystems.com wrote:
First, suppose d = gcd(x, y, z); then for some x', y', z' we have that
x = d*x', y = d*y', z = d*z'; and so for any a, b, c:
could you explain the notation?
what is the difference btw x and x' ?
what is x
On Aug 15, 2010, at 11:51 PM, Ian Kelly wrote:
On Sun, Aug 15, 2010 at 4:36 PM, Baba raoul...@gmail.com wrote:
Hi Mel,
indeed i thought of generalising the theorem as follows:
If it is possible to buy n, n+1,…, n+(x-1) sets of McNuggets, for
some
x, then it is possible to buy any number of
On Mon, Aug 16, 2010 at 4:23 AM, Roald de Vries downa...@gmail.com wrote:
I suspect that there exists a largest unpurchasable quantity iff at
least two of the pack quantities are relatively prime, but I have made
no attempt to prove this.
That for sure is not correct; packs of 2, 4 and 7 do
On Mon, Aug 16, 2010 at 11:04 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
On Mon, Aug 16, 2010 at 4:23 AM, Roald de Vries downa...@gmail.com wrote:
I suspect that there exists a largest unpurchasable quantity iff at
least two of the pack quantities are relatively prime, but I have made
no
On Aug 16, 2010, at 5:04 PM, Ian Kelly wrote:
On Mon, Aug 16, 2010 at 4:23 AM, Roald de Vries downa...@gmail.com
wrote:
I suspect that there exists a largest unpurchasable quantity iff at
least two of the pack quantities are relatively prime, but I have
made
no attempt to prove this.
That
On Aug 16, 1:23 am, Roald de Vries downa...@gmail.com wrote:
On Aug 15, 2010, at 11:51 PM, Ian Kelly wrote:
On Sun, Aug 15, 2010 at 4:36 PM, Baba raoul...@gmail.com wrote:
Hi Mel,
indeed i thought of generalising the theorem as follows:
If it is possible to buy n, n+1,…, n+(x-1) sets
On Mon, Aug 16, 2010 at 12:43 PM, Roald de Vries downa...@gmail.com wrote:
I'm pretty sure that if there's no common divisor for all three (or more)
packages (except one), there is a largest unpurchasable quantity. That
is: ∀
i1: ¬(i|a) ∨ ¬(i|b) ∨ ¬(i|c), where ¬(x|y) means x is no divider of
Hi Chas, Roald,
These are all complicated formula that i believe are not expected at
this level. If you look at the source (see my first submission) you
will see that this exercise is only the second in a series called
Introduction to Programming. Therefore i am convinced that there is
a much
Baba wrote:
[ ... ]
Now, i believe that the number of consecutive passes required to make
this work is equal to the smallest number of pack sizes. So if we have
packs of (9,12,21) the number of passes needed would be 9 and the
theorem would read
If it is possible to buy n,n+1,n+2,...n+8
Baba raoul...@gmail.com writes:
Hi Mel,
indeed i thought of generalising the theorem as follows:
If it is possible to buy n, n+1,~, n+(x-1) sets of McNuggets, for some
x, then it is possible to buy any number of McNuggets = x, given that
McNuggets come in x, y and z packs.
so with
well i still believe that the key is the smallest sized pack and
there's no need to go into higher mathematics to solve this problem.
I think below code works within the limits of the exercise which
states to look at a maximum range of 200 in order not to search
forever.
packages=[2,103,105]
On 8/16/2010 4:18 PM, Baba wrote:
packages=[2,103,105]
min_size=min(packages[0],packages[1],packages[2])
or:
min_size = min(packages)
-John
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 16, 11:04 am, Baba raoul...@gmail.com wrote:
Hi Chas, Roald,
These are all complicated formula that i believe are not expected at
this level. If you look at the source (see my first submission) you
will see that this exercise is only the second in a series called
Introduction to
Hi John,
Thanks for your submission! I've improved a lot and everone's help so
far has been thrilling amd is very good for my self-study
motivation :)
ok so i think i'm clear on how to approach this problem and on how to
write basic but clean Python code to solve it.
The next step is to
Hi John,
Thanks for your submission! I've improved a lot and everone's help so
far has been thrilling and is very good for my self-study
motivation :)
ok so i think i'm clear on how to approach this problem and on how to
write basic but clean Python code to solve it.
The next step is to
On 8/15/2010 8:44 AM Baba said...
Hi John,
Thanks for your submission! I've improved a lot and everone's help so
far has been thrilling and is very good for my self-study
motivation :)
ok so i think i'm clear on how to approach this problem and on how to
write basic but clean Python code to
On Sun, Aug 15, 2010 at 9:58 AM, Emile van Sebille em...@fenx.com wrote:
On 8/15/2010 8:44 AM Baba said...
Hi John,
Thanks for your submission! I've improved a lot and everone's help so
far has been thrilling and is very good for my self-study
motivation :)
ok so i think i'm clear on how
On 8/15/2010 11:38 AM, Baba wrote:
In addition to the points that Emile and Ian made ...
def diophantine_nuggets(x,y,z):
cbc=0 #cbc=can_buy counter
packages =[x,y,z]
You can take advantage of a nifty syntax convenience feature here.
Instead of loading all of the function's
Hi All,
@Emile tnx for spotting the mistake. Should have seen it myself.
@John Ian i had a look around but couldn't find a general version of
below 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
Baba wrote:
Hi All,
@Emile tnx for spotting the mistake. Should have seen it
myself.
@John Ian i had a look around but couldn't find a general
version of
below 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
Hi Mel,
indeed i thought of generalising the theorem as follows:
If it is possible to buy n, n+1,…, n+(x-1) sets of McNuggets, for some
x, then it is possible to buy any number of McNuggets = x, given that
McNuggets come in x, y and z packs.
so with diophantine_nuggets(7,10,21) i would need 7
On Sun, Aug 15, 2010 at 4:36 PM, Baba raoul...@gmail.com wrote:
Hi Mel,
indeed i thought of generalising the theorem as follows:
If it is possible to buy n, n+1,…, n+(x-1) sets of McNuggets, for some
x, then it is possible to buy any number of McNuggets = x, given that
McNuggets come in x, y
On Aug 13, 8:25 pm, Ian Kelly ian.g.ke...@gmail.com wrote:
It's not. You're not just trying to find the sixth value that can be
bought in exact quantity, but a sequence of six values that can all be
bought in exact quantity. The integers [6, 9, 12, 15, 18, 20] are not
sequential.
Hi Ian,
Baba wrote:
def can_buy(n_nuggets):
for a in range (0,n_nuggets):
for b in range (0,n_nuggets):
for c in range (0,n_nuggets):
#print trying for %d: %d %d %d % (n_nuggets,a,b,c)
if 6*a+9*b+20*c==n_nuggets:
return [a,b,c]
On 8/14/10, Baba raoul...@gmail.com wrote:
On Aug 13, 8:25 pm, Ian Kelly ian.g.ke...@gmail.com wrote:
It's not. You're not just trying to find the sixth value that can be
bought in exact quantity, but a sequence of six values that can all be
bought in exact quantity. The integers [6, 9, 12,
On Sat, Aug 14, 2010 at 8:52 AM, Baba raoul...@gmail.com wrote:
my code is probably not elegant but a huge step forward from where i
started:
def can_buy(n_nuggets):
for a in range (0,n_nuggets):
for b in range (0,n_nuggets):
for c in range (0,n_nuggets):
Baba wrote:
On Aug 13, 8:25 pm, Ian Kelly ian.g.ke...@gmail.com wrote:
It's not. You're not just trying to find the sixth value that can be
bought in exact quantity, but a sequence of six values that can all be
bought in exact quantity. The integers [6, 9, 12, 15, 18, 20] are not
sequential.
On 8/14/2010 10:52 AM, Baba wrote:
for n_nuggets in range(50):
result1 = can_buy(n_nuggets)
result2 = can_buy(n_nuggets+1)
result3 = can_buy(n_nuggets+2)
result4 = can_buy(n_nuggets+3)
result5 = can_buy(n_nuggets+4)
result6 = can_buy(n_nuggets+5)
if
Martin P. Hellwig wrote:
SPOILER ALTER: THIS POST CONTAINS A POSSIBLE SOLUTION
On 08/12/10 21:41, News123 wrote:
On 08/12/2010 09:56 PM, Martin P. Hellwig wrote:
On 08/11/10 21:14, Baba wrote:
cut
How about rephrasing that question in your mind first, i.e.:
For every number that is
On Aug 12, 2010, at 10:51 PM, John Posner wrote:
On 8/12/2010 9:22 AM, Dave Angel wrote:
Now you have to find the largest number below 120, which you can
easily do with brute force
tgt = 120 # thanks, Dave Angel
Anytime, but I'm not Dave Angel.
My previous algorithm was more efficient,
On Aug 13, 2010, at 12:25 PM, Roald de Vries wrote:
My previous algorithm was more efficient, but for those who like one-
liners:
[x for x in range(120) if any(20*a+9*b+6*c == x for a in range(x/20)
for b in range(x/9) for c in range(x/6))][-1]
OK, I did some real testing now, and there's
Hi News 123,
Ok i'm getting closer. I am able to write code that will output values
that can be bought in exact quantity (truelist) and values that cannot
be bought in exact quantities.
For a range up to 29 i get this:
true [6, 9, 12, 15, 18, 20, 21, 24, 26, 27, 29]
false [0, 1, 2, 3, 4, 5, 7,
Hi News 123,
Ok i'm getting closer. I am able to write code that will output values
that can be bought in exact quantity (truelist) and values that cannot
be bought in exact quantities.
For a range up to 29 i get this:
true [6, 9, 12, 15, 18, 20, 21, 24, 26, 27, 29]
false [0, 1, 2, 3, 4, 5, 7,
On Fri, Aug 13, 2010 at 12:25 PM, Baba raoul...@gmail.com wrote:
Hi News 123,
Ok i'm getting closer. I am able to write code that will output values
that can be bought in exact quantity (truelist) and values that cannot
be bought in exact quantities.
For a range up to 29 i get this:
true
Roald,
What would your solution be if you weren't allowed to 'know'
that 120 is an upper limit.
Assume you were only allowed to 'know', that you won't find
any other amount, which can't be bought A AOON A
you found six solutions in a row?
I have a rather straightforward solution trying from 0
On 8/13/2010 6:25 AM, Roald de Vries wrote:
On Aug 12, 2010, at 10:51 PM, John Posner wrote:
On 8/12/2010 9:22 AM, Dave Angel wrote:
Now you have to find the largest number below 120, which you can
easily do with brute force
tgt = 120 # thanks, Dave Angel
Anytime, but I'm not Dave Angel.
Hi BAba,
On 08/13/2010 09:25 PM, Ian Kelly wrote:
On Fri, Aug 13, 2010 at 12:25 PM, Baba raoul...@gmail.com wrote:
Hi News 123,
Ok i'm getting closer. I am able to write code that will output values
that can be bought in exact quantity (truelist) and values that cannot
be bought in exact
Baba wrote:
level: beginner
exercise: given that packs of McNuggets can only be bought in 6, 9 or
20 packs, write an exhaustive search to find the largest number of
McNuggets that cannot be bought in exact quantity.
exercise source:
Baba raoul...@gmail.com writes:
exercise: given that packs of McNuggets can only be bought in 6, 9 or
20 packs, write an exhaustive search to find the largest number of
McNuggets that cannot be bought in exact quantity.
Is that a homework problem? Hint: first convince yourself that a
largest
On Aug 12, 2010, at 11:33 AM, Paul Rubin wrote:
Baba raoul...@gmail.com writes:
exercise: given that packs of McNuggets can only be bought in 6, 9 or
20 packs, write an exhaustive search to find the largest number of
McNuggets that cannot be bought in exact quantity.
Is that a homework
Roald de Vries wrote:
div class=moz-text-flowed style=font-family: -moz-fixedOn Aug
12, 2010, at 11:33 AM, Paul Rubin wrote:
Baba raoul...@gmail.com writes:
exercise: given that packs of McNuggets can only be bought in 6, 9 or
20 packs, write an exhaustive search to find the largest number
Baba wrote:
Thank You for helping me out. Indeed i am not looking for the code but
rather for hints that direct my reasoning as well as hints as to how
to write basic programs like this.
You have broken down the approach into 2 parts. I have tried to solve
part 1 but i'm not quite there
On Aug 12, 2010, at 9:02 PM, Peter Otten wrote:
Baba wrote:
Thank You for helping me out. Indeed i am not looking for the code
but
rather for hints that direct my reasoning as well as hints as to how
to write basic programs like this.
You have broken down the approach into 2 parts. I
Hi Baba,
The last tips should really help you getting started:
for testing your function you could do:
Below your uncorrected code and a test for it
def can_buy(n_nuggets):
for a in range (1,n_nuggets):
for b in range (1,n_nuggets):
for c in range (1,n_nuggets):
One more small tip to verify whether your code is working:
On 08/12/2010 10:28 PM, News123 wrote:
Hi Baba,
Your code, but returning the result as suggested in my preious post:
def can_buy(n_nuggets):
for a in range (1,n_nuggets):
for b in range (1,n_nuggets):
for c
On 8/12/2010 9:22 AM, Dave Angel wrote:
Now you have to find the largest number below 120, which you can
easily do with brute force
Dept of overkill, iterators/generators division ...
-John
#--
from itertools import imap, product, ifilter
from operator import mul
box_sizes
On 08/12/2010 10:51 PM, John Posner wrote:
On 8/12/2010 9:22 AM, Dave Angel wrote:
Now you have to find the largest number below 120, which you can
easily do with brute force
Dept of overkill, iterators/generators division ...
-John
#--
from itertools import imap,
On 8/12/2010 6:31 PM, News123 wrote:
candidate_box_counts = product(
xrange(target/box_sizes[0] + 1),
xrange(target/box_sizes[1] + 1),
xrange(target/box_sizes[2] + 1),
)
Couldn't this be rewritten as:
candidate_box_counts = product(
* [
In message mailman.1996.1281605023.1673.python-l...@python.org, Jean-
Michel Pichavant wrote:
for mcNugget in range(0,10):
sendTo(trashbin)
Ah, but should that be
mcNugget.sendTo(trashbin)
or
trashbin.insert(mcNugget)
?
--
http://mail.python.org/mailman/listinfo/python-list
level: beginner
exercise: given that packs of McNuggets can only be bought in 6, 9 or
20 packs, write an exhaustive search to find the largest number of
McNuggets that cannot be bought in exact quantity.
exercise source:
On Wednesday 11 August 2010, it occurred to Baba to exclaim:
level: beginner
exercise: given that packs of McNuggets can only be bought in 6, 9 or
20 packs, write an exhaustive search to find the largest number of
McNuggets that cannot be bought in exact quantity.
The MacDonald's at
58 matches
Mail list logo