import copy


def get_column_sizes(content, is_bold=False, has_spacing=True, preferred_sizes=None):
    """
    - content: (Array string), the column content
    - is_bold: Bool, True if the column content must be surrounded with '**'
    - has_spacing: Bool, True if we keep at least one space padding between cell border
    - preferred_sizes: None or (Array int), the preferred sizes of the columns.
      Will be at least this size
    RETURN: (Array int), the actual sizes
    """
    if preferred_sizes is None:
        sizes = [0] * len(content)
    else:
        sizes = copy.deepcopy(preferred_sizes)
    assert len(content) == len(sizes), "len(content) must equal len(sizes)"
    for col_num, col_name in enumerate(content):
        atoms = col_name.replace('\n',' ').split(' ')
        longest_atom = max([len(s) for s in atoms])
        if is_bold:
            num_atoms = len(atoms)
            if num_atoms == 1:
                longest_atom += 4
            elif num_atoms > 1:
                longest_atom += 2
        if has_spacing:
            longest_atom += 2
        if longest_atom > sizes[col_num]:
            sizes[col_num] = longest_atom
    return sizes