Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Brick Moving 1

Status
Not open for further replies.

Tarwn

Programmer
Mar 20, 2001
5,787
0
0
US
Note: I just made this up, so who knows how easy or hard it will be :)

The purpose is to write a function to calculate the cheapest possible cost of building a wall based on the number of bricks required for the wall and the distance between the brick store and the site of the future wall. Your method of moving bricks from the store to the site of the future wall are by generic carriers that you have hired, arranged in a firemans line. Each carrier accepts a brick from one side (either another carrier or the store) and delivers it to the other side (either the next carrier or the final site)

Givens:
You have an unlimited pool of brick carriers.
Brick carriers cost $5/hr
Bricks cost $20
Brick Carrier Movement:
Brick carriers take 20 seconds to turn 180 degrees whether or not they are carrying a brick
Distance covered by a carrier turning 180 degrees is .5 meters
Brick carriers walk at .5 meters/second when carrying a brick
Brick carriers walk at .75 meters/second when unburdened (conserving their strength)

Assumptions:
You will only have one line of brick carriers, no parellel distribution lines


The function or query you write will accept the target number of bricks and distance (in meters) between the store and the brick pile/wall. The best solution is the one that is the cheapest. Return the cheapest cost, number of carriers, and amount of time.


I believe I covered all the variables from my notes, but if something obvious is missing please let me know. For the sake of comparison, lets see the results for:
50 bricks at 10 meters
50 bricks at 20 meters
100 bricks at 100 meters
1000 bricks at 100 meters

barcode_1.gif
 
I like this one. Will be a good weekend project if I get bored.
 

Tarwn,

A great puzzle -- and almost certainly beyond my meagre brainpower, although I'll give it a try.

One observation: I can't see why the cost of a brick is relevant? For a given wall and distance, the total cost won't vary with the cost per brick. The aim, surely, is to minimise the transport costs. Or have I got it completely wrong?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I included it for completeness. :p

barcode_1.gif
 

Tarwn,

Fair enough.

Can we add a couple of assumptions?

- The carriers must be evenly-spaced.

- Each carrier must always hand a brick to another carrier (or deposit it at the wall); each carrier must always receive a brick from another carrier (or collect it from the store)? In other words, they are not allowed to leave bricks on the ground, from where another carrier can pick them up later.

Does that sound reasonable to you? I would think these assumptions would simplify the solution a bit.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Yep, thanks for adding those. I assumd them without even realizing it.

barcode_1.gif
 
Hmmmm....

Let's start with the simplest one to work out - a single carrier carrying each brick the whole way. If d is the distance to the wall, the time taken (in seconds) to carry each brick there is

2(d - 0.5) + 20 = 2d + 19

He's then got to turn round and come back, which takes

4(d - 0.5)/3 + 20 = (4d + 58)/3

So a complete round trip, carrying a brick there and coming back for the next takes

(10d + 115)/3

Now, for b bricks, we can multiply the above number by b, and subtract the time taken for coming back at the end - he can do that in his own time! The grand total is

(b(10d + 115) - (4d + 58))/3

That's in seconds, multiply by 5/3600 to get it into dollars.

The calculation for two or more carriers is totally different, as we don't have to worry about the time taken to walk back. Consider two carriers A & B: A carries a brick half-way, hands to B, B carries it forward while A walks back, by the time B dumps the brick & walks back A's walking forward. Bricks are always moving and never waiting for a walk-back.

So how long does it take n men to carry each brick d metres?

2(d - 0.5n) + 20n = 2d + 19n

The complication here is that multiple men can have multiple bricks along the chain at once...

Two men can keep one brick moving.

With three, there's 2 bricks: A is handing one to B as C is dumping one.

With four, there's still two: A's picking one up and B hands one to C as D drops one.

With five, A's handing to B as C hands to D as E drops one.

The bottom line is - as the last man drops a brick, the next one is already (n-2)/n of the way to the end. This means (I think) that to work out the total time taken, we should add the total time taken for the first brick to (2/n) of the time for each other brick, to allow for the overlapping journeys:

2d + 19n + 2(b-1)(2d + 19n)/n

= (2b + n - 2)(2d + 19n)/n

That's the elapsed time in seconds, but we need to multiply it by n to get it into person-seconds:

(2b + n - 2)(2d + 19n)

Again multiplying this by 5/3600 will get you dollars.

What this means is that it's never worth hiring more than two men if you only care about the money - the higher the value of n, the higher the cost.

What I haven't worked out is if it's sometimes cheaper to hire two men over one? Two men will cost 2b(2d + 38) person-seconds, are there values for b & d where this is less than (b(10d + 115) - (4d + 58))/3 ? My instinct is that it might be, for a small number of bricks carried over a long distance.

STOP PRESS: Limited tinkering with Excel suggests that I'm wrong: It's always cheapest to hire one man.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Hmmm, too early to check your numbers but I'm wondering if I should have worked this out ahead of time before posting it :p

barcode_1.gif
 
There's a simpler way to reach the same conclusion.

If you have a simple case beloved of school maths books everywhere in which the time is inversely proportional to the number of carriers:

1 man takes 1 hour to move a pile of bricks
2 men take 30 minutes
3 men take 20 minutes
... etc ...

All options cost the same amount of money: halving the time doubles the cost-per-hour. It's gonna cost $5 to move that pile however many (or few) men you throw at it.

So the only question you have to answer is "will two men get the job done more than twice as fast as one?". With the set-up you describe, considering for example that the bricks are moving more slowly with more men in the line, the answer's pretty clearly "No". That being the case, one man is always going to be the cheapest.

That's also gonna be the expected value from real life - adding more people gets the job done quicker, but costs more.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
A star for your effort Chris.

Are all "generic brick carriers" created equally, or is that another Post entirerly? :)



[thumbsup2] Wow, i'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top