def spq_encode(answers):
    """Function that receives an array of 20 answers and encodes the results
       for the SPQ survey. It returns the following tuple:

       (DA: Deep approach,
        SA: Surface approach,
        DM: Deep motive,
        SM: Surface motive,
        DS: Deep strategy,
        SS: Surface strategy)

        They are the averages of the corresponding questions.
        :param answers: Array of 20 answers that encodes the results of the
        survey
    """

    dm_idx = [1, 5, 9, 13, 17]
    ds_idx = [2, 6, 10, 14, 18]
    sm_idx = [3, 7, 11, 15, 19]
    ss_idx = [4, 8, 12, 16, 20]

    # Calculate the four accumulations first
    dm_val = 1.0 * sum([answers[i - 1] for i in dm_idx])
    ds_val = 1.0 * sum([answers[i - 1] for i in ds_idx])
    sm_val = 1.0 * sum([answers[i - 1] for i in sm_idx])
    ss_val = 1.0 * sum([answers[i - 1] for i in ss_idx])

    # Return the six values
    return ((dm_val + ds_val) / (len(dm_idx) + len(ds_idx)),
            (sm_val + ss_val) / (len(sm_idx) + len(ss_idx)),
            dm_val / len(dm_idx),
            sm_val / len(sm_idx),
            ds_val / len(ds_idx),
            ss_val / len(ss_idx))