I have to following problem to solve. I have to calculate the bidding price from a total price. For example, a client wants to pay 2000$ as a total price, but from this price, there are added costs:
-usage price which is 10% from the bidding price with a minimum of 10$ and a maximum of 50$
-seller price: 2% from bidding price
-added price: 5$ for a bid between 1 and 500 10$ for a bid between 501 and 1000 15$ for a bid between 1001 and 3000 20$ for a bid over 3000$
-storing cost: 100$
from all this, I have to calculate the bidding price for a total of 2000$, for example. I kind of have no clue of how this can be done. Can anyone give me some hints or pieces of answer of what the algorithm should be?
EDIT: ok I got how to calculate the algebra, now where i’m stuck is how to write the algorithm in code or pseudo-code. Anyone got a hint?
You can express all those costs as a function of the bid price. Generate a giant equation that is the sum of all those functions and solve for a particular final value, e.g.:
So the final cost is something like:
Solve for a particular value and you’re done.
For example, if you want the total cost to be $2000:
Bid must be at least > 1500 and < 2000, which works out nicely since we can make those PIN sections constant:
The PIN expressions are the hardest to factor out, so you might have to guess a few times until you get something that narrows down the range of bids you want to calculate.