A few people rate a film from 0 to 10, and each one hears what their friends think. Write update(opinions, friends): everyone’s new opinion after hearing their friends. friends[i] lists the positions of person i’s friends. Your own opinion counts as one voice too.
Five friends rate a film from 0 to 10. Each person hears their friends’ ratings, their own included, and everyone updates at the same moment. What is each person’s new opinion? Click anyone to see who they hear.
update(opinions, friends)| opinions | one number per person | e.g. [3, 3, 3] |
| friends | friends[i] lists the positions of person i's friends | e.g. [[1, 2], [0], [0]] |
| returns | everyone's new opinion after hearing their friends (your own counts as one voice too) | |