Remove duplicate pack_rectangles

This commit is contained in:
2024-06-16 22:51:48 +02:00
parent 7b73aef5fe
commit 859c83745b
22 changed files with 1 additions and 20 deletions

View File

@@ -57,25 +57,6 @@ class Bin:
self.grid[rect_y][rect_x] = False
def pack_rectangles(rectangles, grid):
rectangles = sorted(
rectangles, key=lambda r: r.width * r.height, reverse=True)
bins = [Bin(grid)]
for rectangle in rectangles:
for bin in bins:
if bin.place_rectangle(rectangle):
break
else:
new_bin = Bin(grid)
if new_bin.place_rectangle(rectangle):
bins.append(new_bin)
else:
return False
return True
def generate_rectangle(min_width: int = 10, max_width: int = 25):
width = randint(min_width, max_width)
height = randint(min_width, max_width)