0% found this document useful (0 votes)
4 views1 page

Optimize Box Packing Algorithm

Uploaded by

Anshul Somani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Optimize Box Packing Algorithm

Uploaded by

Anshul Somani
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

vector LESS_THAN int GREATER_THAN packItemsInBoxes( vector LESS_THAN vector

LESS_THAN int GREATER_THAN GREATER_THAN items, vector LESS_THAN vector LESS_THAN


int GREATER_THAN GREATER_THAN boxes ) OPEN_BRACE
sort( [Link] OPEN_PAREN CLOSE_PAREN, [Link] OPEN_PAREN CLOSE_PAREN,
OPEN_BRACKET const vector LESS_THAN int GREATER_THAN& a, const vector LESS_THAN int
GREATER_THAN& b CLOSE_BRACKET OPEN_BRACE
return a OPEN_SQUARE 1 CLOSE_SQUARE LESS_THAN b OPEN_SQUARE 1 CLOSE_SQUARE;
CLOSE_BRACE );
sort( [Link] OPEN_PAREN CLOSE_PAREN, [Link] OPEN_PAREN CLOSE_PAREN,
OPEN_BRACKET const vector LESS_THAN int GREATER_THAN& a, const vector LESS_THAN int
GREATER_THAN& b CLOSE_BRACKET OPEN_BRACE
return a OPEN_SQUARE 1 CLOSE_SQUARE LESS_THAN b OPEN_SQUARE 1 CLOSE_SQUARE;
CLOSE_BRACE );

int p EQUALS 0, ip EQUALS 0, i EQUALS 0, j EQUALS 0;

while ( i LESS_THAN [Link] OPEN_PAREN CLOSE_PAREN AND j LESS_THAN


[Link] OPEN_PAREN CLOSE_PAREN ) OPEN_BRACE
if ( items OPEN_SQUARE i CLOSE_SQUARE OPEN_SQUARE 1 CLOSE_SQUARE
EQUALS_EQUALS boxes OPEN_SQUARE j CLOSE_SQUARE OPEN_SQUARE 1 CLOSE_SQUARE )
OPEN_BRACE
p PLUS_PLUS;
if ( items OPEN_SQUARE i CLOSE_SQUARE OPEN_SQUARE 0 CLOSE_SQUARE
EQUALS_EQUALS boxes OPEN_SQUARE j CLOSE_SQUARE OPEN_SQUARE 0 CLOSE_SQUARE )
OPEN_BRACE
ip PLUS_PLUS;
CLOSE_BRACE
i PLUS_PLUS;
j PLUS_PLUS;
CLOSE_BRACE else if ( items OPEN_SQUARE i CLOSE_SQUARE OPEN_SQUARE 1
CLOSE_SQUARE LESS_THAN boxes OPEN_SQUARE j CLOSE_SQUARE OPEN_SQUARE 1
CLOSE_SQUARE ) OPEN_BRACE
i PLUS_PLUS;
CLOSE_BRACE else OPEN_BRACE
j PLUS_PLUS;
CLOSE_BRACE
CLOSE_BRACE

return OPEN_CURLY_BRACE p, ip CLOSE_CURLY_BRACE;


CLOSE_BRACE

You might also like