Yeah I got my fake arrays working!
BTW this line in code:
Dim pile(5)....
was totally ignored by BRUN as this line did not start with keyword!
In the other had all the lines that start with . are printed and all the variables in that line translated to their values.
Code:
' and 1 for the monkey problem B.txt adopted for BRUN v2 to test string new string array functions get and put
' and 1 for the monkey problem.bas for JB 2.0 b 2018-02-11
n start 100
. i (bluatigro) fount this puzle in a book:
. there are 5 person's + 1 monkey
. they shipwrek on a Island
. the fisrst day they colect kokonut's
.
. day 1:"
. I (bplus) am starting with a number of coconuts.
n cc start
dim pile(5) this is why we need string array! for 5 piles
. Say the coconuts collected by the people is start .
.
. in the night happens this:
. (each) person goes to the pile
. divides it in 5 hides 1/5
. and gives 1 to the monkey
.
. I (bplus) am paying the monkey first.
. I (bplus) am not cutting any coconuts into parts of coconuts.
.
. So Coconut inventory after first night:
do
n persn persn + 1
if persn > 5
exit
fi
n cc cc - 1
n monk monk + 1
put piel persn int(cc/5)
n cc cc - int(cc/5)
get p piel persn
. For person persn , their pile is p
loop
. and monkey has monk
.
. day 2"
. the 2e day"
. thay divide the remaining pile in 5"
. and give 1 to the monkey"
. now calc the size of every pile"
.
. Coconuts starting day 2, before final divvy is cc
n cc cc - 1
n monk monk + 1
n divee int(cc/5)
. After monkey gets one more coconut the divvy is divee
.
n persn 1
do
get p piel persn
n p p + divee
put piel persn p
n persn persn +1
if persn > 5
exit
fi
loop
n Remain start
n persn 1
do
get p piel persn
. For person persn , their pile is p
n Remain Remain - p
n persn persn + 1
if persn > 5
exit
fi
loop
. The monkey has monk coconuts.
n Remain Remain - monk
.
. Coconuts remaining are Remain for the monkey who programmed this inventory.
BTW this line in code:
Dim pile(5)....
was totally ignored by BRUN as this line did not start with keyword!
In the other had all the lines that start with . are printed and all the variables in that line translated to their values.
B += x