Sharing marbles
A group of children share marbles from a bag. The first child takes one marble and a tenth of the remainder. The second child takes two marbles and a tenth of the remainder. The third child takes three marbles and a tenth of the remainder. And so on until the last child takes whatever is left. Knowing that all the children end up with the same number of marble, how many children were there and how many marbles did each one get?
Labels: mathschallenge





17 Comments:
81
Posted by the Godson
Sorry The Godson, that's wrong. I also wanted two numbers.
The good news; you did get the "Puzzlarian Golf" right. I've posted a comment there.
Zaux. Unless it's going cheap etc., I wouldn't bother too much with Black Adder series 1.
Marbles =1 or 81
Total Marbles= 1
Kid: 1 Marbles = 1
Total Marbles= 81
Kid: 1 Marbles = 9
Kid: 2 Marbles = 9
Kid: 3 Marbles = 9
Kid: 4 Marbles = 9
Kid: 5 Marbles = 9
Kid: 6 Marbles = 9
Kid: 7 Marbles = 9
Kid: 8 Marbles = 9
Kid: 9 Marbles = 9
Hi Ragknot. Those are the right numbers. Nice one for getting the 1,1 case. Can you provide a ToM explanation?
Chris...
the entire Black Adder series is on amazon for $81 ...
Of course 1 marble does not fit the wording, but it works for 1 child.
"How many marbles did each one get?"
9 not 81
That sounds OK. BA1 just isn't anything like as good as the others.
how many children were there
9
and how many marbles did each one
get?
9
Ragknot. I knew 81 was a typo, I allowed for that - it's not a problem. I'm more than happy to accept the 1,1 case too.
First I'd like to explain why I solve the ToM's like I do. My job (at work) is to find solutions. Not for just one problem, but to find a solution for a problem that may occur in many different places. And the answers will be different because the inputs will be different. I particular work on engineering solutions. Trick of Mind gives me practice in programming solutions in ways unique way.
I could have used trial and error and logic and algebra to solve a ToM, but that solution would be unique to that problem. If I can program a solution for varied inputs, it may become usable over a wide range of inputs. A Trick of Mind has never exactly solved an engineering problem. But it does help me become more proficient in using programming tools.
For this one, I saw there were comments already, but I just copied the problem and pasted it to a blank program module, and then wrote a few steps that would find a solution that fit the requirements.
My goal is not to find the answers but to write a way to program a solution. Another way to say this is, I write a program that I can sent to dozens of offices that will find the solutions for varied inputs.
Speciffically for this ToM, I did not think about ONE being a solution, but my program allowed ONE, so I included it when it popped out on the first loop.
I also found solutions for 1/100 of a marble and 1/100 of a kid just to see the results. You may note some lines left over from non integer solutions.
If anyone understand this very short code, please let me know.
'Sharing marbles
'A group of children share marbles from a bag.
'The first child takes one marble and a tenth of the
'remainder. The second child takes two marbles and a
'tenth of the remainder. The third child takes three
'marbles and a tenth of the remainder. And so on until
'the last child takes whatever is left. Knowing that all
'the children end up with the same number of marble,
'how many children were there and how many marbles did
'each one get?
Sub KidsMarbles()
Dim Kid(1000)
For x = 1 To 1000
Marbles = x
For k = 1 To 1000
Kid(k) = k
Marbles = Marbles - k
M = Marbles / 10
Kid(k) = Kid(k) + M
Marbles = Marbles - M
If Abs(Marbles) < 0.001 Then
Debug.Print "Total Marbles="; x
For j = 1 To k
Debug.Print "Kid:"; j; " "; "Marbles = "; Kid(k)
Next j
End If
Next k
Next x
End Sub
RagKnot, have you ever checked out the Euler Project? Chock full of problems best solved by programs like that. I think they're up to about 300 problems. Some very, very challenging.
Here's my attempt at solving this analytically instead of brute force.
Call the total N.
The first kid takes one plus a tenth of the remainder:
[1] A = 1 + (N-1)/10
10A = 10 + N - 1
10A-9 = N
The second kid takes two plus a tenth of the new remainder. But, we're also told her total is the same as the first kid. So:
[2] A = 2 + ((N-A)-2)/10
10A = 20 + N-A-2
11A - 18 = N
Equating these two sides:
10A-9 = 11A-18
A = 9
N = 10*A-9 = 90-9 = 81
And if each child takes 9 marbles and there were 81 to start, then there must be 9 children.
You may wonder .. why doesn't this method come up with the degenerate case of one child? Because, if there is no second child, then equation two does not hold.
thanks Ross, I will check it out
Ragknot. I'm sure that you are aware that your code is quick and dirty, but it does do the job, and any refinements would only be worth doing if the code really was going to be re-used. It is nice that the method produces the 1,1 solution. A weakness is that it hasn't checked that that each kid got the same number of marbles. But in view of the actual result, that's nit-picking. Besides, I suspect that neither my nor Ross's solution are any better as far as that goes.
Ross. I hadn't thought to try that particular approach. It does, of course, assume that the problem is soluble. I fancy that my solution has the same flaw.
Of course, we all verified that in fact all the kids did get the same number of marbles. So we are forgiven.
Here's my solution:
Let m and c be the number of marbles and children. The total
number of marbles is mc.
For the first child, 1 + (mc-1)/10 = m => m(10-c) = 9
At this point can say that either m = 1 and 10-c = 9,
m = 3 and 10-c = 3, or m = 9 and 10-c = 1.
=> m,c = 1,1 or 3,7 or 9,9. We can disregard 3,7 as there must be at least as many marbles as kids.
So we have m,c = 1,1 or m,c = 9,9
Another solution: Let m, c be marbles/kid and #kids.
Let n be number of children to go, then require
(c-n) +((n+1)m -(c-n))/10 = m
=> 9c = 9m + n(9-m).
This must be true for all n, therefore 9-m = 0 => m = 9
=> c = m = 9. This skips the c = m = 1 case.
This argument guarantees that all kids receive the same number
of marbles.
The Godson. I'm sorry; I was having a senior moment, and hadn't noticed that your 81 was for the total number of marbles.
Post a Comment
Links to this post:
Create a Link
<< Home