Spooky Sale: 10% off Premium yearly · $118.80 for the first year · until Nov 6Get it

Deep-ML
Learn
Problems1,200+ hands-on ML problemsLearning PathA guided route through the fundamentalsLabsInteractive labs on real techniquesProjectsBuild a GPT, an RL agent, CUDA kernelsCollectionsCurated problem sets and videosMathPen-and-paper math for MLIntuitionInvent the idea behind the formula yourselfPlaylistsYour own problem lists, shareableStudy AssistantAn AI teacher that knows your progress
Interview Prep
Compete
ContestsFresh problem sets, ranked liveLeaderboardWhere you stand, globallyBuddiesSolve with a friend: streaks, a weekly board, chat
Discuss
Deep-Path
Premium
      Intuition
      98 of 102

      Listen to your friends

      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.

      Five friends rated a film. A line joins two people who hear each other.2Ana8Ben4Cai10Dee6Eveupdate(opinions, friends) → [?, ?, ?, ?, ?]
      Your functionupdate(opinions, friends)
      opinionsone number per persone.g. [3, 3, 3]
      friendsfriends[i] lists the positions of person i's friendse.g. [[1, 2], [0], [0]]
      returnseveryone's new opinion after hearing their friends (your own counts as one voice too)
      solution.pyLoading Python
      Sign in for an AI hint
      ← Grade on a curveFade to static →