On Aug 18, 11:50 am, John Posner 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* har
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 cas
On Aug 18, 10:52 am, Baba 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 nuggets by just
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 n
On Aug 17, 2:44 pm, Baba wrote:
> On Aug 16, 6:28 pm, "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
On 08/17/2010 11:44 PM, Baba wrote:
> On Aug 16, 6:28 pm, "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 diff
On Aug 16, 6:28 pm, "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 = d*x', y supposed
Paul Rubin writes:
> Baba 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?
yes, and no
it was a homework p
On Aug 16, 11:04 am, Baba 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 Programming". The
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
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]
min_s
Baba 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 diophantine_nugge
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
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 si
On Mon, Aug 16, 2010 at 12:43 PM, Roald de Vries 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: ∀
>>> i>1: ¬(i|a) ∨ ¬(i|b) ∨ ¬(i|c), where ¬(x|y) means "x is no divider of y"
>>
On Aug 16, 1:23 am, Roald de Vries wrote:
> On Aug 15, 2010, at 11:51 PM, Ian Kelly wrote:
>
>
>
> > On Sun, Aug 15, 2010 at 4:36 PM, Baba 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
>
On Aug 16, 2010, at 5:04 PM, Ian Kelly wrote:
On Mon, Aug 16, 2010 at 4:23 AM, Roald de Vries
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 co
On Mon, Aug 16, 2010 at 11:04 AM, Ian Kelly wrote:
> On Mon, Aug 16, 2010 at 4:23 AM, Roald de Vries 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 f
On Mon, Aug 16, 2010 at 4:23 AM, Roald de Vries 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 have a large
On Aug 15, 2010, at 11:51 PM, Ian Kelly wrote:
On Sun, Aug 15, 2010 at 4:36 PM, Baba 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, give
On Sun, Aug 15, 2010 at 4:36 PM, Baba 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 and z packs
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 pa
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
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
M
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 argumen
On Sun, Aug 15, 2010 at 9:58 AM, Emile van Sebille 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 ho
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 sol
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 generali
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 generali
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 result1!=[]
Baba wrote:
On Aug 13, 8:25 pm, Ian Kelly 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,
Thanks for
On Sat, Aug 14, 2010 at 8:52 AM, Baba 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):
> #print "tryin
On 8/14/10, Baba wrote:
> On Aug 13, 8:25 pm, Ian Kelly 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
>> sequenti
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
On Aug 13, 8:25 pm, Ian Kelly 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,
Thanks for stating
Hi BAba,
On 08/13/2010 09:25 PM, Ian Kelly wrote:
> On Fri, Aug 13, 2010 at 12:25 PM, Baba 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 quantitie
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.
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 Fri, Aug 13, 2010 at 12:25 PM, Baba 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 [6, 9, 12, 1
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, 8,
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, 8,
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 s
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, b
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:
>>>
>>>
>>> How about rephrasing that question in your mind first, i.e.:
>>>
>>> For ev
In message , 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
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(
* [ xrange
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
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 =
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
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):
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 have
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 th
Roald de Vries wrote:
On Aug
12, 2010, at 11:33 AM, Paul Rubin wrote:
Baba 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
On Aug 12, 2010, at 11:33 AM, Paul Rubin wrote:
Baba 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 con
Baba 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 number actually
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:
http://ocw.mit.edu/courses/electrical-engineering-and-computer
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 Nur
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:
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-
58 matches
Mail list logo