Jump to content
BrainDen.com - Brain Teasers
  • 0

PowerCo


BMAD
 Share

Question

PowerCo has three plants that must provide enough electricity to four cities. Shipping to each city from the various plants costs varying amounts. Moreover each plant has a set supply of energy that it can send to the various cities. The specifics of this information are outlined in the chart below:

From City 1 City 2 city 3 city 4 Supply

Plant 1 $8 $6 $10 $9 35

Plant 2 $9 $12 $13 $7 50

Plant 3 $14 $9 $16 $5 40

Demand 45 20 30 30

How can PowerCo best minimize its costs?

  • Upvote 1
  • Downvote 1
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Plant 1: 10 to City 2 @ $6 and 25 to City 3 @ $10

Plant 2: 45 to City 1 @ $9 and 5 to City 3 @ $13

Plant 3: 10 to City 2 @ $9 and 30 to City 4 @ $5

Total Cost = $1020

As par for the course, this could probably have be made a lot more elegantly, but it seems to get the job done.

Fair warning: this took about 20 seconds to spit out an answer. Feel free to uncomment the cout after the first for loop if you are really into countdowns.

int a, b, c, d, e, f, g, h, i, j, k, l, a1, b1, c1, d1, e1, f1, g1, h1, i1, j5, k1, l1, money=10000;

int main()
{
    for(a=35; a>=0; a--)
    {
        //cout<<a<<endl;
        for(b=((35-a)>20 ? 20 : (35-a)); b>=0; b--)
        {
            for(c=((35-(a+>30 ? 30 : (35-(a+); c>=0; c--)
            {
                d=35-(a+b+c);

                for(e=45-a; e>=0; e--)
                {
                    for(f=((50-e)>20 ? 20 : (50-e)); f>=0; f--)
                    {
                        for(g=((50-(e+f))>30 ? 30 : (50-(e+f))); g>=0; g--)
                        {
                            h=50-(e+f+g);

                            for(i=((a+e)<5 ? 0 : 45-(a+e)); i>=0; i--)
                            {
                                if(a+e+i==45)
                                {
                                    for(j=((40-i)>20 ? 20 : (40-i)); j>=0; j--)
                                    {
                                        if(b+f+j==20)
                                        {
                                            for(k=((40-(i+j))>30 ? 30 : (40-(i+j))); k>=0; k--)
                                            {
                                                if(c+g+k==30)
                                                {
                                                    l=40-(i+j+k);

                                                    if(d+h+l==30 and (8*a+6*b+10*c+9*d+9*e+12*f+13*g+7*h+14*i+9*j+16*k+5*l)<=money)
                                                    {
                                                        money=(8*a+6*b+10*c+9*d+9*e+12*f+13*g+7*h+14*i+9*j+16*k+5*l);
                                                        a1=a;b1=b;c1=c;d1=d;
                                                        e1=e;f1=f;g1=g;h1=h;
                                                        i1=i;j5=j;k1=k;l1=l;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    cout<<a1<<"  "<<b1<<"  "<<c1<<"  "<<d1<<endl<<e1<<"  "<<f1<<"  "<<g1<<"  "<<h1<<endl<<i1<<"  "<<j5<<"  "<<k1<<"  "<<l1<<endl<<"= $"<<money<<endl;
	return 0;
}

Link to comment
Share on other sites

  • 0

plant 1 should send 30 to city 3 @ $10 and it's remaining 5 to city 2 @ $6 = $330


plant 2 should send 45 to city 1 @ $9 and its remaining 5 to city 4 @ $7 = $440
plant 3 should send 25 to city 4 @ $5 and 15 to city 2 @ $9 = $260
for a total cost of $930 I think that's the best they can do.
  • Downvote 1
Link to comment
Share on other sites

  • 0

plant 1 should send 30 to city 3 @ $10 and it's remaining 5 to city 2 @ $6 = $330

plant 2 should send 45 to city 1 @ $9 and its remaining 5 to city 4 @ $7 = $440

plant 3 should send 25 to city 4 @ $5 and 15 to city 2 @ $9 = $260

for a total cost of $930 I think that's the best they can do.

Your score adds up to 1030 but there is actually a more optimal answer

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...