-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calculation is wrong on buying multiple processor power #7
Comments
Found it! You need the starting number, the multiplier and the increment. (S+M-1) x (S+M)/2 x I - (S-1) x S/2 x I = Total cost If you want 10 multiplier, with 1 increment starting from 1 You are now at 11. Lets buy 10 more And that's it :) |
Hi, thanks for providing this, really appreciate it. I've spent time this past week looking at the problem. Lets start with the status quo:
However this is a brute force approach, calculating each step one by one. So this loop is not efficient at all. Running the loop for large numbers seriously slows the application down. So the formula you provided has been very useful. It does indeed work when calculating the cost of large numbers. This is how I've currently set up your formula on a test branch (still in development):
I'm still in the works on implementing this formula, (thanks again for it). It would really help me out if you can add more details around the break down you added in the second comment. Could you explain the details of what each part of the formula is doing please? Cheers dude 👍 |
I had a problem with buying processor power. For example, now my cost is 6.213.800. If I try to buy 100, it returns 'toast inventory low, 621.380.000 toast matter needed#', which is the current cost x 100. The first part of the example I mentioned is from a step you still have no increased cost. So
It works like this: You want to buy 100, so it applies the first formula, so it gives you the cost from zero to 100. This type of increase is called triangular number. I didn't know it before. Learned it because of the toast! |
Each time you buy processor power, it changes the cost of the next one.
However, if you buy multiple, it doesn't consider the increase between them
For example(Not the actual numbers):
Lets say the increase is 1 per each buy.
If the cost is 1, and I buy 1, I "pay" 1 toast and then next cost then would be 2.
However, if the cost is 1 and I buy 10, I pay 10 toast ant the following cost would be 11.
The correct cost would be 55 (1+2+3+4+5+6+7+8+9+10).
Will try to find the math formula that does this.
The text was updated successfully, but these errors were encountered: