Board Logo
« and 1 for the monkey problem »

Welcome Guest. Please Login or Register.
Feb 25th, 2018, 7:57pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: and 1 for the monkey problem  (Read 72 times)
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1273
xx and 1 for the monkey problem
« Thread started on: Feb 11th, 2018, 2:37pm »

http://libertybasic.conforums.com/index.cgi?board=LB3&action=display&num=1518341687

Hi bluatigro,

Are we to use Algebra to say in formula what the size of pile is each day? Not much good with programs but I guess you could write a sub that takes in n coconuts for parameter and then calcs the piles count of all the parties involved.

Is that it?
« Last Edit: Feb 11th, 2018, 2:38pm by bplus » User IP Logged

B+
bplus
Senior Member
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1273
xx Re: and 1 for the monkey problem
« Reply #1 on: Feb 11th, 2018, 4:05pm »

Well first to post a solution to this puzzle!

Code:
' and 1 for the monkey problem.bas for JB 2.0 b 2018-02-11

start = 100
print "   i (bluatigro) fount this puzle in a book :"
print "     there are 5 person's + 1 monkey"
print "     they shipwrek on a Island"
print "     the fisrst day they colect kokonut's"
print
print "day 1:"
print "I (bplus) am starting with a number of coconuts."
coconuts = start
dim pile(5)
Print "Say the coconuts collected by the people is ";start;"."
print
print "     in the night happens this :"
print "     eats (each) person goes to the pile"
print "     divides it in 5 hides 1/5"
print "     and gives 1 to the monkey"
print
print "I (bplus) am paying the monkey first."
print "I (bplus) am not cutting any coconuts into parts of coconuts."
print
Print "So Coconut inventory after first night:"
for person = 1 to 5
    coconuts = coconuts - 1 ' and 1 for the monkey
    monkey = monkey + 1     ' and 1 for the monkey
    pile(person) = int(coconuts / 5)
    coconuts = coconuts - int(coconuts / 5)
   print "For person ";person;", their pile is ";pile(person)
next
print "             and monkey has ";monkey
print
print "day 2"
print "      the 2e day"
print "      thay divide the remaining pile in 5"
print "      and give 1 to the monkey"
print "      now calc the size of every pile"
print
print "Coconuts starting day 2, before final divy is ";coconuts
coconuts = coconuts - 1 ' and 1 for the monkey
monkey = monkey + 1     ' and 1 for the monkey
divy = int(coconuts/5)
print "after monkey gets one more coconut the divy is ";divy
print
for person = 1 to 5
    pile(person) = pile(person) + divy
next
Remaining = start
For person = 1 to 5
    print "For person ";person;", their pile is ";pile(person)
    Remaining = Remaining - pile(person)
next
print "The monkey has ";monkey;" coconuts."
Remaining = Remaining - monkey
print
print "Coconuts remaining are ";Remaining;" for the monkey who programmed this inventory."

 


I have a taste for some coconut pie, bye!
User IP Logged

B+
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls