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

Home > Just Math
Dafoe, The Lone Entrepreneur (Posted on 2006-01-30) Difficulty: 3 of 5
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.)
Some Thoughts computer solution--not necessarily best | Comment 7 of 23 |

In writing the program some assumptions had to be made, such as, it makes no sense to delay a purchase when the money was available previously.  Still, we can't assume that it's best to buy whatever you can--it might be worthwhile to save up for a more expensive property than you can afford right now, as the more expensive properties give a better return on investment: it's better to have one shopping center than 15 shacks. On the other hand it's never advantageous to avoid buying a shopping center, as there's no better investment around to save up for.

So the program is written recursively to explare all branches of the tree, initially up to a depth of 40 days, but as $1000 is reached sooner, the depth allowed is lowered to the earliest reach of $1000 that had been achieved.

The choices at each point are: buy nothing, buy a shack, buy a mall, buy as many shopping centers as you can afford.  As written, there's no provision for buying more than one type of property.  Here's the best it came up with:

day avl prc sh ma sc  $remain
     $  typ
 1    5 0    1  0  0    5
 2   10 1    2  0  0    0
 3   10 1    3  0  0    0
 4   15 1    4  0  0    5
 5   25 2    4  1  0    0
 6   35 2    4  2  0   10
 7   60 2    4  3  0   35
 8  100 2    4  4  0   75
 9  155 3    4  4  1    5
10  235 3    4  4  2   85
11  465 5    4  4  5   15
12  845 0    4  4  5  845
13 1675 0    4  4  5 1675

The columns show the day (days after the start), the number of dollars available in the morning, the purchase type (0=nothing, 1=shack, 2=mall, 3=one shopping center, 4=two shopping centers, 5=three shopping centers), the number of shacks owned, the number of malls owned, the number of shopping centers owned, and the amount left after the purchases.

The daily $5 is assumed to come from a pre-existing shack, so the "shacks owned" shows what may be one more than reality if the $5 comes from elsewhere.

The lack of capability of more than one type of purchase adversely affects the wealth building above.  For example, on day 6 Dafoe could have bought an additional shack with the extra $10.  It would have paid itself back by day 8, so there'd still be no problem in purchasing the shopping center on day 9. Or on day 8, two malls could have been bought instead of one.

DECLARE SUB addOn ()
DEFINT 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 = 40
shacks = 1

addOn

SUB addOn
  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
    FOR choice = 0 TO 3
     IF amount >= cost(choice) THEN
       amount = amount - cost(choice)
       hist2(dayNo) = amount
       SELECT CASE (choice)
         CASE 1: shacks = shacks + 1
         CASE 2: malls = malls + 1
         CASE 3: centers = centers + 1
            DO
             IF amount >= cost(3) THEN
              amount = amount - cost(3)
              hist2(dayNo) = amount
              centers = centers + 1
              choice = choice + 1
             END IF
            LOOP UNTIL amount < cost(3)
       END SELECT
       p(dayNo) = choice
       hs(dayNo) = shacks
       hm(dayNo) = malls
       hc(dayNo) = centers

       addOn

       p(dayNo) = 0
       IF choice >= 3 THEN numc = choice - 2: choice = 3:  ELSE numc = 1
       SELECT CASE (choice)
         CASE 1: shacks = shacks - 1
         CASE 2: malls = malls - 1
         CASE 3: centers = centers - numc
       END SELECT
       amount = amount + cost(choice) * numc
     END IF
    NEXT
   END IF
  END IF
  amount = aSave
  dayNo = dayNo - 1
END SUB

 


  Posted by Charlie on 2006-01-31 09:31:54
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (5)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information