Giter Site home page Giter Site logo

most_wishlisted_movie_sorting's Introduction

most_wishlisted_movie_sorting

This is 18_5_2019's morning challenge

  • Implement topWatchlistedMoviesAmongFriends method that will return an array of top four movie titles, that have been most watchlisted by friends of a given user.

  • If there are no such movies, then an empty list should be returned or as many movies as possible.

  • Movies that have equal watchlist count, should be ordered alphabetically.

  • Below are your movies and users array

let movies = [{ "title": "The Shawshank Redemption", "duration": "PT142M", "actors": [ "Tim Robbins", "Morgan Freeman", "Bob Gunton" ], "ratings": [], "watchlist": [15291, 51417, 62289, 6146, 71389, 93707] }, { "title": "The Godfather", "duration": "PT175M", "actors": [ "Marlon Brando", "Al Pacino", "James Caan" ], "ratings": [], "watchlist": [62289, 66380, 34139, 6146] }, { "title": "The Dark Knight", "duration": "PT152M", "actors": [ "Christian Bale", "Heath Ledger", "Aaron Eckhart" ], "ratings": [], "watchlist": [51417, 62289, 6146, 71389, 7001] }, { "title": "Pulp Fiction", "duration": "PT154M", "actors": [ "John Travolta", "Uma Thurman", "Samuel L. Jackson" ], "ratings": [], "watchlist": [7001, 9250, 34139, 6146] }, { "title": "Schindler's List", "duration": "PT195M", "actors": ["Liam Neeson", "Ralph Fiennes", "Ben Kingsley"], "watchlist": [15291, 51417, 7001, 9250, 93707] }];

let users = [{ "userId": 15291, "email": "[email protected]", "friends": [7001, 51417, 62289] }, { "userId": 7001, "email": "[email protected]", "friends": [15291, 51417, 62289, 66380] }, { "userId": 51417, "email": "[email protected]", "friends": [15291, 7001, 9250] }, { "userId": 62289, "email": "[email protected]", "friends": [15291, 7001] }];

E.g. topWatchlistedMoviesAmongFriends(62289), should return:

["Schindler's List", "Pulp Fiction", "The Dark Knight", "The Shawshank Redemption"]

In the example above, user with id 62289 has two friends: user with id=15291 and with id=7001. Schindler's List is watchlisted by both users, so it will be the most watchlisted.

E.g. topWatchlistedMoviesAmongFriends(15291), should return:

["The Dark Knight", "Schindler's List", "The Shawshank Redemption", "Pulp Fiction"]

In the example above, user with id 15291 has three friends: users with id=7001, id=51417 and id=62289. The Dark Knight is the most watched. Schindler's and Shawshank have both been watched twice, so will be in alphabetical order. Pulp Fiction and The Godfather have both been watched once, but Pulp fiction comes earlier alphabetically ("P.." vs "T.."), so it makes the top 4.

most_wishlisted_movie_sorting's People

Contributors

joshua-tu avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.