Question
Write a file named matchmaker.py that contains a collection of functions that will help you find the compatibility between various things. The main idea used
Write a file named matchmaker.py that contains a collection of functions that will help you find the compatibility between various things.
The main idea used in these functions will be finding the overlap between lists of elements. These will be done as follows:
1.1 agreement(i1, i2)
Given two lists of interests, return a list of the shared interests between the two. Do not modify the provided lists. The order of elements in the returned list does not matter. You may assume that both i1 and i2 are lists or tuples and that neither contains a duplicate element.
For example, agreement(['games', 'museums', 'food'], ['art', 'food', 'hiking', 'games']) should return either ['games', 'food'] or ['food', 'games']
1.2 disagreement(i1, i2)
Given two lists of interests, return a list of interests in only one list. Do not modify the provided lists. The order of elements in the returned list does not matter. You may assume that both i1 and i2 are lists or tuples and that neither contains a duplicate element.
For example, disagreement(['games', 'museums', 'food'], ['art', 'food', 'hiking', 'games']) should return some permutation of ['museums', 'art', 'hiking']
1.3 compatibility(i1, i2)
Given two lists of interests, return a compatibility score for the two. This is computed as the number of shared interests divided by the total number of interests: shared(shared+notshared) Do not modify the provided lists. You may assume that both i1 and i2 are lists or tuples and that neither contains a duplicate element.
For example, compatibility(['games', 'museums', 'food'], ['art', 'food', 'hiking', 'games']) should return 0.4 because there are five interests listed in total, of which only 2 are shared.
I have code for this, but apparently it's not passing all of the test cases for the homework assignment and I'm not sure why. If I could see an example of code that would work for this, that would be very helpful in learning why my code may not be working completely. Thank you!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started