Last active
December 26, 2015 09:49
-
-
Save be9/7131763 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. Find the row (i-th) with max total width | |
| 2. Sort the images, so that widest goes first and narrowest last. | |
| 3. Loop for all images in i-th starting from widest (image A): | |
| 4. For each other row (j-th): | |
| 5. Try to move image A to j-th row. That is, if TotalSize[j] + width[A] < TotalSize[i], move and stop. Improvement done. | |
| 6. Loop from narrowest to widest image in j-th row (image B): | |
| 7. if max(TotalSize[j] - width[B] + width[A], TotalSize[i] - width[A] + width[B]) < TotalSize[i] | |
| then swap image A and image B. Improvement done. | |
| 8. If no move nor swap could be made during the run, the split is "unimprovable". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment