Solved

logic problem:4 greedy brothers

Posted on 2004-03-23
13
421 Views
Last Modified: 2011-10-03
There are 4 brothers who are to greedy and they have a dog and a bottle of cookies. The first brother wakes up at night and goes to the kitchen and does the next thing.
Firstly, he gives a cookie to the dog and secondly he eats the 4th part of the cookies that are left. nd he  comes back to bed. After this the second brother wakes up and does the same thing, what it means that he gives one cookie to the dog and the eats the 4th part of the cookies that are left.

The third brother does the same thing and the 4th brother too.  The next  day when they are going to take the breakfast(the 4 brothers), first they give 1 cookie to the dog and after they divide the cookies that are left in equals parts(by 4).

The question is how many cookies there were in the bottle? I have to solve this problem by natural language, and a type of logic that is a mixture of predicate logic and mathematical logic, could somebody help me , please? Thank you
0
Comment
Question by:tucurruane
  • 4
  • 4
  • 2
  • +1
13 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 30 total points
ID: 10656565
1021 or 2045 or 3069 or 4093 or ...
0
 

Expert Comment

by:HansMichel
ID: 10692433
Hi.

Late but here

(1 + ((x - 1)/4) = T_1,
(1 + (T_1 - 1)/4) = T_2,
(1 + ((T_2 - 1)/4) = T_3,
(1 + ((T_3 - 1)/4) = T_4,
(1 + ((T_4 - 1)/4) = T_5 = 0.

(1 + ((x - 1)/4) = T_1,
(1 + ((1 + ((x - 1)/4) - 1)/4) = T_2,
(1 + (((1 + ((1 + ((x - 1)/4) - 1)/4) - 1)/4) = T_3,
(1 + (((1 + (((1 + ((1 + ((x - 1)/4) - 1)/4) - 1)/4) - 1)/4) = T_4,
(1 + (((1 + (((1 + (((1 + ((1 + ((x - 1)/4) - 1)/4) - 1)/4) - 1)/4) - 1)/4) = T_5 = 0.

There exist an x such that (1 + (((1 + (((1 + (((1 + ((1 + ((x - 1)/4) - 1)/4) - 1)/4) - 1)/4) - 1)/4) = 0

Hans
0
 

Expert Comment

by:HansMichel
ID: 10692535
Hi again.

Last post is not correct so ignore lead to a negative answer (-1983) no negative cookies.

However this leads to

T1 = ((x  - 1)/4);
T2 = ((T1  - 1)/4);
T3 = ((T2 - 1)/4);
T4 = ((T3  - 1)/4);
T5 = ((T4 - 1)/4);
4*(T5)  - 5 = 0;

T1 = (1/4)*(-1 + x);
T2 = (1/4)*(-1 + (1/4)*(-1 + x))
T3 = (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x)))
T4 = (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x))))
T5 = (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x)))))


4*T5  = -1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x))))
4*T5 - 5 = -6 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x))))
-6 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x)))) = 0

Solve for x

x = 1621

There exist an x such that -6 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + (1/4)*(-1 + x)))) = 0


Hans
0
 
LVL 84

Expert Comment

by:ozo
ID: 10692636
If you allow negative cookies, -3 is a trivial answer,
Also, since you divide by 4  5 times, the difference between any two solutions must be a multiple of 1024
0
 

Expert Comment

by:HansMichel
ID: 10693999
Hi.
This turned out to be a more interesting question than I previously thought. As for how to put this in formal logic or natural language I can't help right now. Disregard my last reply; because when I plug in 1621 back into the equations I end up with Reals or fractional parts for the brothers.
 Brother 1 = 1620/4 = 405
 Brother 2 = 404/4 = 101
 Brother 3 = 100/5 = 25
 Brother 4 = 24/4 = 6
Next Day
 5/4 = 1.25 cookies for the brothers each.  Nothing wrong with that except that you have fractional cookies for the brothers. Dog always gets 1.
ozo's first solution
 Brother 1 1020/4 = 255
 Brother 2 254/4 = 63.5
 Brother 3 62.5/4 = 15.625
 Brother 4 14.625/4 = 3.65625
Next Day
 2.65625/4 = 0.6640625
But if you assume no negative cookies, no fractional cookies, or imaginary cookies for any one. Then the problem becomes more elagant and also interesting.
So x is 1365
1364/4 = 341
340/4 = 85
84/4 = 21
20/4 = 5
4/4 = 1
Now the sequence {0,1,5,21,85,341,1365, ...} is a very interesting sequence.
              a_n = (4^n - 1)/3
If one brother got up again and gave the dog one cookie and took 1/4 the remainder then there would have been 5461 cookies.
What is interesting about this sequence is that if you represent these number is negabinary  or binary they are equivalent.
{0,1,101,10101,1010101,101010101,10101010101, ...}

This problem in tems of composition of function is represented as
f(x) = ((x - 1)/4)
f(f(f(f(f(x))))) = 1.
When ever f^n(x) = 1 then x =  (4^n - 1)/3.
Hans
See
http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eisA.cgi?Anum=A002450

http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eisA.cgi?Anum=A001045

http://mathworld.wolfram.com/Negabinary.html
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 84

Expert Comment

by:ozo
ID: 10695346
Each brother eats (n-1)/4 cookies, leaving (n-1)*3/4 cookies
0
 

Expert Comment

by:HansMichel
ID: 10695641
Hi.
Yes trivial. (n -1)/4 eaten, 3(n -1)/4 left. Let (n-1)  = a; a/4 eaten 3a/4 left. a/4 + 3a/4 = a(1/4 + 3/4). Also figured out where you get 1024 {0,1,5,21,85,341,1365, ...} difference between numbers.
{1,4,16,64,256,1024,4096, ...}

So x is 1365
1364/4 = 341
340/4 = 85
84/4 = 21
20/4 = 5
4/4 = 1

This sequence {0,4,20,84,1364, ...} is equivalent to (n-1)*3/4.
This sequence {0,1,5,21,85,341,1365, ...} is equivalent to (n-1)/4.

I leave it to the originator of the question to sort out which is simpler.

Hans
0
 
LVL 84

Expert Comment

by:ozo
ID: 10696171
If x is 1365 then you'd get
1364 - 1364/4 = 1023 left, not 341
0
 
LVL 2

Expert Comment

by:Bob_Everard
ID: 10705523
Natural language(?, well as natural as possible):
The number of cookies at each stage is one more than a multiple of 4, which is the same thing as saying it's 3 LESS than a multiple of 4.
Considering one brother: when he opens the jar it contains 4*X-3 cookies. He gives a cookie to the dog, leaving 4*X-4 (easily seen to be divisible by 4). He eats a quarter of these, leaving three quarters, (3/4)*(4*X-4) = (3/4)*X - 3, which is the same form as the original number.

Let's choose a number F, which is some multiple of 4, such that the original number of cookies in the jar is F-3. After each brother has done his bit, the number of cookies in the jar must be 3^4*F/4^4 - 3. In the morning they give one to the dog, leaving 3^4*F/4^4 - 4. This is divisible by 4 if F = 4^5 (= 1024).
 
Brother #1 finds 1021, gives one to the dog, eats 255, leaving 765
Brother #2 finds  765, gives one to the dog, eats 191, leaving 573
Brother #3 finds  573, gives one to the dog, eats 143, leaving 429
Brother #4 finds  429, gives one to the dog, eats 107, leaving 321
In the morning, they find 321, give one to the dog, and each eat 80 cookies.

They must be pretty stupid brothers not to notice the difference between 1021 and 321.

This is a slight variation on one found earlier here involving 5 sailors, a mass of coconuts and a monkey.
0
 
LVL 5

Expert Comment

by:PointyEars
ID: 10782815
Let's start from the "end" of the problem.

In the morning each brother eats n cookies and the dog 1. This adds up to:
  4*n + 1
before breakfast. When the 4th brother entered the kitchen at night, there were therefore:
  (4*n + 1)*4/3 + 1
cookies.  This multiplication by 4/3 and addition of the cookie for the dog must be repeated 3 more times (one for each brother) in order to obtain N, the initial number of cookies in the jar.

This means that N is given by:
  N = (n*4^5 + 4^4 + 4^3*3 + 4^2*3^2 + 4*3^3 + 3^4) / 3^4   ==>
  N = (1024*n + 781)/81   ==>
  N = n*1024/81 + 781/81

81 fits 9 times into 781, with a remainder of 52.  Therefore:
  N = n*1024/81 + 52/81 + 9   ==>
  N = 4*(n*256/81 + 13/81) + 9

81 fits 3 times into 256, with a remainder of 13.  Therefore:
  N = 4*(3*n + (n + 1)*13/81) + 9

It is now clear that  all solutions are obtained when (n+1)/81 is integer:
  n = k*81 -1

The first solution is therefore, consistently with other proposed solutions, n = 80 and N = 1021.  The next solution is n = 161 and N = 2045...
0
 
LVL 5

Expert Comment

by:PointyEars
ID: 10976287
Well, I find that you should also recognise those who have given an explanation for the results, like in:
  N = 4*(3*n + (n + 1)*13/81) + 9
It is now clear that  all solutions are obtained when (n+1)/81 is integer:
  n = k*81 -1
The first solution is therefore, consistently with other proposed solutions, n = 80 and N = 1021.  The next solution is n = 161 and N = 2045...

Without making names...     :-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Have you ever thought of installing a power system that generates solar electricity to power your house? Some may say yes, while others may tell me no. But have you noticed that people around you are now considering installing such systems in their …
We are taking giant steps in technological advances in the field of wireless telephony. At just 10 years since the advent of smartphones, it is crucial to examine the benefits and disadvantages that have been report to us.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now