Pairs

A company sometimes needs to send two workers to perform repairs. To
form the pairs, he has the data of the workers in a dictionary in which
the key is the name of a worker and the value is the list with the names
of the rest of the workers with whom they are disposed to work. Although
worker ’pepe’ may be willing to work with ’paco’, it does not imply that
’paco’ is willing to work with ’pepe’. It is possible that some worker
does not want to work with anyone.

1.  When a worker leaves the company his entry is deleted from the
    dictionary, but the name may continue to appear on other workers’
    lists.

    Program a function @limpia(preferencias)@ which, given a dictionary
    @preferencias@ as described at the beginning, returns a new
    dictionary in which the names of the workers who are no longer in
    the company have been removed, that is, the ones that are no longer
    keys.

2.  The company needs to send workers to make repairs. Program a
    function @empareja(ltrab, preferencias)@, which given a list @ltrab@
    of company workers each destined for a different repair, and a
    dictionary @preferencias@ like the one described at the beginning,
    returns a dictionary that associates each employee assigned to
    repairs with the possible companions (those who are they prefer each
    other but are not intended for another repair service).

Scoring

Part 1: 45 puntos.

Part 2: 55 puntos.

Sample session

Problem information

Author: InfBesos

Generation: 2026-01-25T13:42:14.837Z

© Jutge.org, 2006–2026.
https://jutge.org
