Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this investment problem, you are give $T , which is the total amount you can invest on n. Product x (x is a number

In this "investment" problem, you are give $T, which is the total amount you can invest on n. Product x(x is a number between 0 and n-1) has a cost, c[x] and a profit p[x]. The goal is to maximize the profit without spending more than $T.

Example:

Product A B C D
Cost 24 10 10 7
Profit 24 18 18 10

If T = 24, the best investment is to spend $20 (out of $24) to buy products B and C and make $36 in profit.

The API of your program looks like this:

def invest(T, Costs, Profits):

#return a number, which is the best profit you can make.

You will have to do two thing:

* Explain your strategy cleanly and neatly in English

* Write a python program to implement your strategy.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

Describe how language reflects, builds on, and determines context?

Answered: 1 week ago