Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
rectangles + combinations solution in Clear category for Grid Painting by kdim
from itertools import combinations
def grid_painting(cells):
rectangles = []
for y in range(5):
for x in range(5):
for h in range(1, 6 - y):
for w in range(1, 6 - x):
rectangle = ''.join(chr(j * 5 + i + 65)
for j in range(y, y + h)
for i in range(x, x + w))
if set(rectangle) <= set(cells):
rectangles.append(rectangle)
for n in range(len(rectangles)):
for combination in combinations(rectangles, n + 1):
if len(cells) == len(set(''.join(combination))):
return n + 1
Jan. 23, 2024
Comments: