Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
400 B
1
Indexable
Never
def create_diagonals(objects, backgrounds):
    n = len(objects)
    diagonals = [[] for _ in range(2*n-1)]
    for i in range(n):
        for j in range(n):
            diagonal_index = i+j
            diagonals[diagonal_index].append(objects[i] + '_' + backgrounds[j])
    diagonals_with_4_items = [diagonal for diagonal in diagonals if len(diagonal) == 4]
    return diagonals_with_4_items