def merge(line):
    """
    Helper function that merges a single row or column in 2048
    """
    result = [0] * len(line)
    
    result_position = 0
    
    # iterate over all line values
    for line_value in line:
        if line_value != 0:
            # merge two tiles
            if result[result_position] == line_value:
                result[result_position] = 2 * line_value
                result_position += 1
            # put in blank spot
            elif result[result_position] == 0:
                result[result_position] = line_value               
            # add to next position for a non-matching, occupied spot
            else:
                result_position += 1
                result[result_position] = line_value
        
    return result