Problem 366
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.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
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
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.
-
thundre
- Posts: 356
- Joined: Sun Mar 27, 2011 10:01 am
Problem 366
This is the second week that the new problem has been unavailable for the first hour. DOS attack?
I have a question about the problem, though.
What is M(1)?
"The first player may remove any positive number of stones, but not the whole pile."
There is no legal move for the first player if you start with one stone. Is M=0 in that case?
I have a question about the problem, though.
What is M(1)?
"The first player may remove any positive number of stones, but not the whole pile."
There is no legal move for the first player if you start with one stone. Is M=0 in that case?

- jaap
- Posts: 588
- Joined: Tue Mar 25, 2008 3:57 pm
- Contact:
Re: Problem 366
There's a (repeated) spelling error in the problem - it should be "losing", not "loosing".
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 366
Thanks. Corrected.jaap wrote:There's a (repeated) spelling error in the problem - it should be "losing", not "loosing".

War ruins the life and health of untold numbers of innocent children.
- Marcus_Andrews
- Administrator
- Posts: 1637
- Joined: Wed Nov 09, 2011 5:23 pm
Re: Problem 366
thundre: M(1) = 0, for all intents and purposes; I think the problem description should be rephrased a bit to ask for 2<=n<=10^18 instead.
-
sivakd
- Posts: 217
- Joined: Fri Jul 17, 2009 9:37 am
- Location: California, USA
- Contact:
Re: Problem 366
While I had the same dilemma initially, IMHO, since the problem states "∑M(n) for n≤100 is 728. " shouldn't be too hard to figure what should be expected of M(1).

puzzle is a euphemism for lack of clarity
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 366
How about:
Let M(n) be the maximum number of stones the first player can take from a winning position at his first turn and M(n)=0 for any other position.
?
War ruins the life and health of untold numbers of innocent children.
-
thundre
- Posts: 356
- Joined: Sun Mar 27, 2011 10:01 am
Re: Problem 366
I prefer Marcus' suggestion -- exclude n=1 from the summation domain by specifying 2 <= n <= 1018. That case makes no sense as a game, and I don't think it adds anything to the problem.hk wrote:How about:Let M(n) be the maximum number of stones the first player can take from a winning position at his first turn and M(n)=0 for any other position.?

- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 366
In fact I don't see the need of any change in the wording at all.
If you look at this site: http://sps.nus.edu.sg/~limchuwe/cgt/cgt1.htm
you will see that positions that are not winning, are considered losing.
That also holds for positions where no legal move is possible.
If you look at this site: http://sps.nus.edu.sg/~limchuwe/cgt/cgt1.htm
you will see that positions that are not winning, are considered losing.
That also holds for positions where no legal move is possible.

War ruins the life and health of untold numbers of innocent children.
- jaap
- Posts: 588
- Joined: Tue Mar 25, 2008 3:57 pm
- Contact:
Re: Problem 366
But there the rules are that the first person who does not have a legal move available loses. In this problem it states that the person to take the last stone wins. These two definitions are only equivalent if there is always a legal move while there are still stones in the pile.hk wrote:In fact I don't see the need of any change in the wording at all.
If you look at this site: http://sps.nus.edu.sg/~limchuwe/cgt/cgt1.htm
you will see that positions that are not winning, are considered losing.
That also holds for positions where no legal move is possible.
- Marcus_Andrews
- Administrator
- Posts: 1637
- Joined: Wed Nov 09, 2011 5:23 pm
Re: Problem 366
M(n)=0 is defined for a losing position if I am eventually going to lose. I can only lose if the opponent wins by taking the last stone. If a player can't even take a stone to begin with, how can we define who's won or lost? While it's not hard to figure out what the n=1 case should equate to for convenience, I feel it's still an exception-case that needs to be either explicitly defined for the sake of descriptive rigor, or excluded from the solution domain altogether.hk wrote:In fact I don't see the need of any change in the wording at all.
If you look at this site: http://sps.nus.edu.sg/~limchuwe/cgt/cgt1.htm
you will see that positions that are not winning, are considered losing.
That also holds for positions where no legal move is possible.
Last edited by Marcus_Andrews on Tue Jan 10, 2012 1:41 pm, edited 1 time in total.
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 366
So why was this proposal discarded? It seems to fit all comments.hk wrote:How about:Let M(n) be the maximum number of stones the first player can take from a winning position at his first turn and M(n)=0 for any other position.?
I do not like the proposal 2<=n<=10^18.

War ruins the life and health of untold numbers of innocent children.
- Marcus_Andrews
- Administrator
- Posts: 1637
- Joined: Wed Nov 09, 2011 5:23 pm
Re: Problem 366
Given the nature of the problem, I think this proposal is fine, too.hk wrote:So why was this proposal discarded? It seems to fit all comments.hk wrote:How about:Let M(n) be the maximum number of stones the first player can take from a winning position at his first turn and M(n)=0 for any other position.?
I do not like the proposal 2<=n<=10^18.
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 366
Made it that way.

War ruins the life and health of untold numbers of innocent children.
-
albert
- Posts: 61
- Joined: Sat Aug 02, 2008 12:36 pm
A nit in euler366
I have a small nit to pick about euler366.
Apparently a starting heap of one stone is valid.
Now the first player may only remove one stone, but not the whole pile, which is one
stone. So there is no move for the first player.
From the result 728 I conclude that M(1) = 0.
There are three kinds of positions, with a winning move, a move that leaves a winning
position and no move at all.
Only for the first category we are counting. I think that is a bit too clever.
Why not just leave a position with 1 stone out?
Groetjes Albert.
Apparently a starting heap of one stone is valid.
Now the first player may only remove one stone, but not the whole pile, which is one
stone. So there is no move for the first player.
From the result 728 I conclude that M(1) = 0.
There are three kinds of positions, with a winning move, a move that leaves a winning
position and no move at all.
Only for the first category we are counting. I think that is a bit too clever.
Why not just leave a position with 1 stone out?
Groetjes Albert.
- Marcus_Andrews
- Administrator
- Posts: 1637
- Joined: Wed Nov 09, 2011 5:23 pm
- rayfil
- Administrator
- Posts: 1412
- Joined: Sun Mar 26, 2006 5:30 am
- Location: Quebec, Canada
- Contact:
Re: Problem 366
@ albert
Please try to post in existing topics related to specific problems. You can easily find them by searching for "Problem XXX", making sure to pad the problem number with leading 0's if it less than 100.
Please try to post in existing topics related to specific problems. You can easily find them by searching for "Problem XXX", making sure to pad the problem number with leading 0's if it less than 100.
When you assume something, you risk being wrong half the time.
-
mdean
- Posts: 206
- Joined: Tue Aug 02, 2011 2:05 am
Re: Problem 366
I haven't exactly been active with Project Euler lately, but I have a feeling this one's going to bug me for a while. I think I have the majority of cases figured out, but some I still have to do out individually at this point. Which probably wouldn't be a big issue if we were dealing with something smaller than a quintillion...

-
cowmandude
- Posts: 1
- Joined: Mon Jan 16, 2012 8:54 pm
Re: Problem 366
I think that I may have misunderstood the problem somehow.
The problem states: "...when n=17 the first player can remove one or four stones. "
I believe that taking 5 stones is a winning move for the first player as per my understanding of the problem. Would someone be willing to play through the game with me and show me where my flaw in understanding is?
Note: I assume that these very low values of n are acceptable to post in the forum. If I'm wrong please let me know!
The problem states: "...when n=17 the first player can remove one or four stones. "
I believe that taking 5 stones is a winning move for the first player as per my understanding of the problem. Would someone be willing to play through the game with me and show me where my flaw in understanding is?
Note: I assume that these very low values of n are acceptable to post in the forum. If I'm wrong please let me know!
- Marcus_Andrews
- Administrator
- Posts: 1637
- Joined: Wed Nov 09, 2011 5:23 pm
Re: Problem 366
To guarantee your winning position, 4 stones is the maximum amount you can remove when n=17.
-
thundre
- Posts: 356
- Joined: Sun Mar 27, 2011 10:01 am
Re: Problem 366
So you leave me 12 stones? I take 1.cowmandude wrote:The problem states: "...when n=17 the first player can remove one or four stones. "
I believe that taking 5 stones is a winning move for the first player
Now there are 11 and you can take 1 or 2. Whichever you choose, I take the complement, bringing the pile down to 8, and depending how we got there, you are limited to either 2 or 4 stones.
If you take 3 or 4, I take the rest and win. If you take 1 or 2, I again take the complement, bringing the total down to 5.

