You are not logged in.
Proportionally decrease the values of one or more lists to reach a target sum.
Consider these three or more lists of integer values:
[30, 0, 100, 50, 30] = 210, Importance = 100
[20, 40, 90, 10, 0] = 160, Importance = 80
[1, 10, 30, 0, 500] = 550, Importance = 60
Their total sum is 920. The goal is to make the new "target" sum of all the lists, for example, 200.
What would be a good way to proportionally decrease the values of the lists to achieve the new sum? The values should remain integers.
Additional:
1. In each list, if necessary, try to decrease the highest values more and decrease the lowest values less or not at all.
2.- Each list can have an additional value called "importance," ranging from 0 to 100. 0 indicates that the values in this list are not used. 60 indicates that we give the list 60% importance. This way, we can make the values in one list lower, favoring the values in the other lists.
If possible, I need an example C function.
Offline
I almost forgot: But we should try to keep the lowest values from decreasing. Example:
Having [30, 0, 100, 90, 30] = 250
Ideally, [30, 0, 70, 70, 30] = 200
Offline
hi RegJose
Welcome to the forum.
I'm not understanding this problem.
Consider these three or more lists of integer values:
[30, 0, 100, 50, 30] = 210, Importance = 100
[20, 40, 90, 10, 0] = 160, Importance = 80
[1, 10, 30, 0, 500] = 550, Importance = 60
The equals looks like you're adding the integers inside the square brackets eg 30 + 0 + 100 + 50 + 30 = 210
But 1 + 10 + 30 + 0 + 500 ≠ 550 so is my interpretation correct and there's a typo here. If not then how does the square bracket numbers give the number after the equals?
Importance looks like its the biggest number inside the square brackets eg 100 is the biggest in the first set. But that fails for the other two sets, so how are you defining importance?
Once I'm clear on those issues it'll be worth reading on.
Thanks,
Bob
Children are not defined by school ...........The Fonz
You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you! …………….Bob
Offline
Same here.
So please provide clear description of the problem.
"Talent hits the target no one else can hit. Genius hits the target no one else can see." - Arthur Schopenhauer
Offline
same here
Every living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
But only a human may have the freedom and ability to oppose his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.
Offline
Can't edit or delete it? Delete this post and we'll start with a new one I've already created. Thanks.
Offline
That's an interesting challenge! Sounds like you're trying to bring a group of numbers down to a target value. It's kind of like when I'm playing the Dinosaur Game and need to lower my score proportionally to avoid getting a game over. Finding that sweet spot where everything balances just right can be tricky, but satisfying when you nail it. Managing multiple lists at once adds another layer of complexity. Good luck!
Offline