def compute_columns(n_items, n_rows):
    """Compute the required number of columns given a number of items
    n_items to be displayed in a grid n_rows x n_cols"""
    if n_rows > n_items:
        return n_items, 1
    d = n_items // n_rows
    n_cols = d + (1 if n_items % n_rows else 0)
    return n_rows, n_cols