Number interpolation and automatic reallocation.

tejan's icon

Hi all. I would like to have n amount of integers that all add up to a specific value and if any one of the n integers get changed, then that difference gets reflected, whether it's addition or subtraction in any one of the other integers. Preferably randomly. But I never want any number to dip below 1.

Example: I have 4 integer boxes and the specific value to be added up to is 16. The boxes are at 4 4 4 4. If I change the first one to 6, I'd like the change to be reflected and the boxes turn into 6 2 4 4. Let's say I change the fourth integer to 10. I'd like the change to reflected to something like 1 1 4 10. Thank you!

Source Audio's icon

if entry is only a single value to a single list member,

then you exclude that list member from sum

and change the rest to fit.

max list sum - this list member.

Question is how do you want to spread change among rest of the list.

you could use vexpr to keep distance of each list member from min/max values,

and when you need to add or subtract, simply send number od increases or decreases

to sorted indexes.

Or you use multislider set to floats and round scaled list output

correcting sum at the end to match set value.