def write_score_summary(scores, analogy_types, filename):
    """
    Write score summary to a string
    :param scores: list of pairs
                   (number of correctly answered questions in category, number of questions in category)
    :param analogy_types:
    :param filename:
    :return: score summary (string)
    """
    # Helper: column width in printout
    w = '120'

    # Header
    out = '-' * int(w) + '\n' + filename + ': score summary' + '\n' + '-' * int(w) + '\n'
    out += '{:<65}\t{:>12}\t{:>12}\t{:>15}\n'.format(
        'Analogy type', '#corr answ', '#questions', 'corr answ [%]')

    # Score summary
    for i, analogy_type in enumerate(analogy_types):
        s = scores[i][0]
        nq = scores[i][1]
        perc = s * 100.0 / nq

        # Write the line containing all information pertaining to this analogy type
        out += '{:<65}\t{:>12}\t{:>12}\t{:>15.4g}\n'.format(analogy_type, s, nq, perc)

    return out