Problem 335

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.

This forum is NOT meant to discuss solution methods for a problem.

In particular don't post any code fragments or results.

Don't start begging others to give partial answers to problems

Don't ask for hints how to solve a problem

Don't start a new topic for a problem if there already exists one


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
Post Reply
grizzley
Posts: 4
Joined: Tue Dec 07, 2010 10:13 am

Problem 335

Post by grizzley »

Problem 335 (View Problem)
Well, actually I don't want to ask a question, I just cannot stop wondering how the beans gather with this algorithm (every possible number of them!). And it seems even starting with other number (e.g. 5 beans and 7 cups) does not change the situation! I would rather expect that there are some numbers of beans/cups that don't have that amazing trait...
gprano
Posts: 5
Joined: Wed Apr 14, 2010 2:44 pm

Re: Problem 335

Post by gprano »

I'm pretty sure i don't give any help for the problem here, edit that if I do.

The operation of gathering will necessarily end up in a cycle, because there is a finite number of positions (given the number of bowls and beans) and the next position depends only on the previous one.
If you consider the set A of the couples (x,y) where x is a state of the bowls and y is the position where you are, then the considered operation is a bijection of A : that is you can do the reverse operation by taking one bean from each bowl starting at the bowl you ended in until you are on an empty bowl, where you put the beans you gathered.
So if you consider now your cycle, taking the first state of the cycle and going on step backwards, you can only be at the last state of the cycle, meaning your cycle start at the first position you took. So for each starting position you will end up in the same one after a finite number of steps.

(hope my english was clear enough here..)
User avatar
Lord_Farin
Posts: 239
Joined: Wed Jul 01, 2009 10:43 am
Location: Netherlands

Re: Problem 335

Post by Lord_Farin »

gprano wrote: If you consider the set A of the couples (x,y) where x is a state of the bowls and y is the position where you are, then the considered operation is a bijection of A : that is you can do the reverse operation by taking one bean from each bowl starting at the bowl you ended in until you are on an empty bowl, where you put the beans you gathered.
You now have shown injection of the operation. This is enough, but strictly speaking, by this argument only, there still could be two disjoint cycles. A nice proof nonetheless 8-)
Image
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 335

Post by jaap »

Lord_Farin wrote:
gprano wrote: If you consider the set A of the couples (x,y) where x is a state of the bowls and y is the position where you are, then the considered operation is a bijection of A : that is you can do the reverse operation by taking one bean from each bowl starting at the bowl you ended in until you are on an empty bowl, where you put the beans you gathered.
You now have shown injection of the operation. This is enough, but strictly speaking, by this argument only, there still could be two disjoint cycles. A nice proof nonetheless 8-)
No, it really is a bijection. There can only be one previous (state,currentbowl) pair that leads to the current position.
And that is why the first position that is repeated is the starting position (otherwise that first repeated position would have two different predecessors). There still are several disjoint cycles, but only one that includes the starting position.
gprano
Posts: 5
Joined: Wed Apr 14, 2010 2:44 pm

Re: Problem 335

Post by gprano »

jaap wrote:No, it really is a bijection. There can only be one previous (state,currentbowl) pair that leads to the current position.
And that is why the first position that is repeated is the starting position (otherwise that first repeated position would have two different predecessors). There still are several disjoint cycles, but only one that includes the starting position.
My mistake, the way I stated it it's not a bijection, only an injection, which definition you precisely wrote here (but then we only use the injection aspect anyways, so it doesn't really matter if it's surjective).
To have a bijection we should restrict ourselves to the (state, currentbowl) where there is at least one bean in the current bowl, and then there is exactly one predecessor for each element.
Waldovski
Posts: 32
Joined: Thu Jul 08, 2010 11:11 am

Re: Problem 335

Post by Waldovski »

Guys you're killing us here. I have the closed-form answer figured out. Only I don't know how to get it with the numbers being so huge. Why-oh-why must they be so big? Surely it's the concept that matters as long as the answer cannot be obtained by brute force? Now I need to learn congruence AND to find a way to deal with numbers above 2^53.

This is the second problem I absolutely have figured out but cannot get the number (the other one is 210). I could go to Wolfram or somewhere similar but I don't want to. You guys are rewarding my steadfastness in not treading cheating territory with larger and larger numbers. Very demoralising.

Oh well, part of the learning process I guess.
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 335

Post by TripleM »

Waldovski wrote:This is the second problem I absolutely have figured out but cannot get the number (the other one is 210).
If you can't get the answer then you certainly haven't absolutely figured it out. The limits in any problem are specifically designed to be large enough for the correct algorithm to solve easily, and any incorrect or suboptimal solution to find very tough.

If you're finding the large limit tough, then you haven't solved the problem.
Post Reply