Algorithm of 102- Ecological Bin Packing

In this problem have three color bottol B, G, C and three recycle or bucket. given some bottol each bucket each color you need to minimum change as a result same color bottol in only one bucket . if more than one combination precedence of alphabatic order.


you have 3 bucket and 3 color so total combination is 3!=6
nedd 3 array b[4],c[4],g[4] and another  a[7]
 a[1]=b[2]+b[3]+g[1]+g[2]+c[1]+c[3]; // BCG
       a[2]=b[2]+b[3]+g[1]+g[3]+c[1]+c[2];// BGC
       a[3]=b[1]+b[3]+g[1]+g[2]+c[2]+c[3];//CBG
       a[4]=b[1]+b[2]+g[1]+g[3]+c[2]+c[3];//CGB
       a[5]=b[1]+b[3]+g[2]+g[3]+c[1]+c[2];//GBC
       a[6]=b[1]+b[2]+g[2]+g[3]+c[1]+c[3];//GCB
then you need check smallest value from a[] and check smallest value index print that index color combination
i.e. if index 4 for smallest value then output CGB.



image

1 comment:

  1. no kidding. so it IS brute force.
    I was thinking that there was some elegant way of determining what color each bin should be rather than compute every permutation.

    Becomes redonculouse for large n. I guess thats why they use the exclamation mark for factorials.

    ReplyDelete

Write your comment - Share Knowledge and Experience