All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Dafoe, The Lone Entrepreneur (Posted on 2006-01-30)
Dafoe, The Lone Entrepreneur is a very ambitious man. He wants to make \$1000 in the shortest amount of time! He starts out with \$0 but is currently receiving \$5 per day and he can purchase the following shops at any given time:

1-Shack. Cost: \$10 Income: \$5/day
2-Mall. Cost \$25 Income \$15/day
3-Shopping Center. Cost \$150 Income \$150/day

The money is always paid in at night and Dafoe can purchase as many new shops as his money allows in the mornings.

What would be the best sequence of shops to be purchased to to have a balance of \$1000 on hand?

How many days would that take?

Money spent comes out of his balance and so is no longer part of the needed total balance of \$1000.

 No Solution Yet Submitted by Leon Rating: 4.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 another computer solution | Comment 9 of 23 |

Modifying the program to allow multiple purchases of possibly different types of property on a given day, we can't allow perpetual non-purchase, so the choices programmed were to buy as many shopping centers as possible, then, from half as many to as many malls as possible, then from half as many to as many shacks as possible, given what's left, we still do not get fewer than 13 days, but we maximize the amount of money, and give Dafoe lots of properties for future earning:

`day \$ at shk ma sc shk ma sc    \$    start  bought     held    remaining 1    5         0   1  0  0    5 2   10   1 00 00   2  0  0    0 3   10   1 00 00   3  0  0    0 4   15   1 00 00   4  0  0    5 5   25      1 00   4  1  0    0 6   35   1 01 00   5  2  0    0 7   55      2 00   5  4  0    5 8   90   3 01 00   8  5  0   35 9  150         1   8  5  1    010  265   1 04 01   9  9  2    511  485      1 03   9 10  5   1012  955   1 01 06  10 11 11   2013 1885         0  10 11 11 1885`

The blank-vs-zero difference is a result of using one displayed number represent all three values.

DECLARE SUB addOn ()
DEFDBL A-Z
CLEAR , , 10000
DIM SHARED lowest, shacks, malls, centers, amount, best
DIM SHARED p(40), dayNo, cost(3), hist(40), hs(40), hm(40), hc(40), hist2(40)
DATA 10,25,150
FOR i = 1 TO 3: READ cost(i): NEXT

lowest = 13
shacks = 1

STATIC ct

dayNo = dayNo + 1
aSave = amount
amount = amount + shacks * 5 + malls * 15 + centers * 150
hist(dayNo) = amount
hist2(dayNo) = amount
IF amount >= 1000 AND (dayNo < lowest OR dayNo = lowest AND amount > best) THEN
lowest = dayNo
best = amount
ct = ct + 1
p(dayNo) = choice
hs(dayNo) = shacks
hm(dayNo) = malls
hc(dayNo) = centers
PRINT dayNo
FOR i = 1 TO dayNo
PRINT USING "## #### ###### ## ## ## ####"; i; hist(i); p(i); hs(i); hm(i); hc(i); hist2(i)
NEXT
PRINT ct
ELSE
IF dayNo < lowest THEN
pce = INT(amount / cost(3))
amt2 = amount - pce * cost(3)
FOR pma = INT(amt2 / (2 * cost(2))) TO amt2 / cost(2)
amt3 = amt2 - pma * cost(2)
FOR psh = INT(amt3 / (2 * cost(1))) TO amt3 / cost(1)
amount = amt3 - psh * cost(1)
hist2(dayNo) = amount
shacks = shacks + psh
malls = malls + pma
centers = centers + pce
hs(dayNo) = shacks
hm(dayNo) = malls
hc(dayNo) = centers
p(dayNo) = psh * 10000 + pma * 100 + pce

shacks = shacks - psh
malls = malls - pma
centers = centers - pce
amount = amt3 + psh * cost(1)
NEXT psh
NEXT pma
END IF
END IF
amount = aSave
dayNo = dayNo - 1
END SUB

 Posted by Charlie on 2006-01-31 14:34:59

 Search: Search body:
Forums (0)