Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ENGINEERING PROBLEM #2:
- Our marketing department has just negotiated a deal with several of the top local
- merchants that will allow us to offer exclusive discounts on various products to our top
- customers every day. The catch is that we may only offer each product to one customer
- and we may only make one offer to each customer.
- Each day we will get the list of products that are eligible for these special discounts. We
- then have to decide which products to offer to which customers. Fortunately our team
- of highly trained statisticians has developed an amazing mathematical model for
- determining which customers are most likely to buy which products.
- With all of the hard work done for us, all we have to do now is implement a program
- that assigns each product to a given customer while maximizing the total suitability of all
- products to all customers. We are going to be busy writing up the patent application for
- this amazing new technology, so we need you to implement the matching program.
- The top-secret algorithm is:
- • If the length of the product name is even, the base suitability score (SS) is the number
- of vowels in the customer’s name multiplied by 1.5.
- • If the length of the product name is odd, the base SS is the number of consonants in
- the customer’s name multiplied by 1.
- • If the length of the product name shares any common factors (besides 1) with the
- length of the customer’s name, the SS is increased by 50% above the base SS.
- Write a program that assigns products to sites in a way that maximizes the total SS over
- the set of customers. Each customer can only have one product and each product can
- only be offered to one customer. Your program should run on the command line and
- take as input two newline separated files, the first containing the names of the products
- and the second containing the names of the customers. The output should be the total
- SS and a matching between customers and products. You do not need to worry about
- malformed input, but you should certainly handle both upper and lower case names.
- Use any language you like as long as it isn’t VB.
- For extra credit, submit a solution in both an imperative language and a functional one,
- using language-specific features (feel free to submit a declarative solution as well, if
- that’s your thing).
Add Comment
Please, Sign In to add comment