Return the height of a valid stack of Boxes. The Boxes must be given in a sorted sequence, where the first element is the bottom of the stack and the last one its top. In other words: the box at index i must be strictly larger in width, height and depth than the box
(seq)
| 59 | |
| 60 | @staticmethod |
| 61 | def height(seq): |
| 62 | """ Return the height of a valid stack of Boxes. |
| 63 | |
| 64 | The Boxes must be given in a sorted sequence, where the first element |
| 65 | is the bottom of the stack and the last one its top. In other words: |
| 66 | the box at index i must be strictly larger in width, height and depth |
| 67 | than the box at index i + 1. AssertionError is raised otherwise. |
| 68 | |
| 69 | """ |
| 70 | |
| 71 | if __debug__: |
| 72 | for index in xrange(0, len(seq) - 1): |
| 73 | assert seq[index] > seq[index + 1] |
| 74 | |
| 75 | return sum(box.height for box in seq) |
| 76 | |
| 77 | @memoize |
| 78 | def find_tallest(self): |