Question: Need implemntation python 3 language. ( Asap ) A music club asks its members upon joining to rank in order of preference, a fixed set

Need implemntation python 3 language. (Asap) A music club asks its members upon joining to rank in order of preference, a fixed set of classic song titles, with rank 1 being the most preferred title, and rank being the member's least preferred. This preference ranking is called the member's preference profile. Members are then allowed to listen to contemporary song titles in the club's library, and as they do so, the club's music app automatically maintains a ranked list of their favourite song titles, called the member's top ranked list. The library contains song titles, each of which is given a unique index from to . Each top ranked list is a list of library indexes (which are independent of the indexes used for the preference profile). The club owner wants to implement a feature that would recommend a song title from the top ranked lists of the members whose preference profiles are the nearest to that of the requestor. He defines the distance between two preference profiles as the the number of times that they disagree on the relative ordering of a given pair of songs. For example, suppose that Alice and Bob are members with the following preference profiles: Alice: Bob: Then this means that Alice likes Song #2 the most, and Song #4 the least, while Bob likes Song #3 the most and Song #5 the least. Observe that both prefer Song #2 over Song #5(because each ranked Song #2 higher than Song #5), so they agree on the song pair (2,5). But they disagree on the song pair (2,3) because Alice likes Song #2 more than she does Song #3, while Bob does not. The song pairs that they disagree on are (2,3),(2,4),(1,5),(3,5),(4,5),(1,3),(1,4), so the distance between their preference profiles is 7. According to the club's owner, the best song to recommend to a member with preference profile , and top ranked list , is the highest ranked song, that is not already in , taken from the top ranked lists of members whose preference distance from is minimum. If there is more than one song with the same ranking that is not in , then the song with the lowest index in the library should be recommended. Given the preference profile and the top ranked list for each of members, determine the best song to recommend to the first member of the list, and print its index in the library. If all the songs on the most similar club members' top ranked lists are already on the first member's list, then return -1. Input Format Line 1: The sizes of the preference profile and top ranked list Line 2: The number of club members The next lines are given as two lines for each index : (a) space separated values indicating member 's preference profile, .(b) space separated integers: indicating member 's top ranked list, . Constraints For each , the sequence will be a permutation of the values in the closed interval . Output Format A single integer indicating the index of the best song to recommend to the first member in the list, or -1 if none exists. Sample Input 05104251345723101572192741613421533171927619991577150231541023272615741275047125437196151198084433190 Sample Output 051 Explanation 0 The first member has a preference profile of and a top 10 list of. The first two preference profiles are the same as the ones described in the example of the description. So, we know that the distance between the first two preference profiles is 7. The distance between and is 3(the disagreement pairs are (1,3),(1,5) and (3,5)). The distance between and is also 3(the disagreement pairs are (1,2),(1,5) and (3,4)). So members 3 and 4 are equally close to member 1. We examine the corresponding top 10 lists to find the highest ranked song index that is not already in the first member's top 10 list. For member 3, Song #72 is the highest ranked song not already in member 1's top 10 list, for member 4 it is Song #51. For each of them the rank of that song is 4, so we have a tie of recommendations for member 1 between Song #51 and Song #72. The tie breaker is the lower valued index, so we output 51 as the result

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!