there are a few numbers,
How can you sort them into 3 bowls that amount was close to each other? (equal)
I may not have a solution, but, by amount do you mean sum or count?
All number = Sum
bowl №1 ~ = sum/3
bowl №2 ~= sum/3
bowl №3 ~= sum/3
or
sum bowl 1 ~ sum bowl 2 ~ sum bowl 3
This sounds like a case for the “LoopWhile” node. A little messy but it should at least give you an idea:
Vikram, Dimitar, Thanks guys!
Vikram algorithm more accurate and fast!
Here is a Design Script version with a little shuffle in between, that sometimes seems to throw up closer results.
This is a very rough approach, seems like it can get very complex if the aim is to ensure that we obtain the best possible result every time.
File: 3bowlsDS.dyn
Vikram, thank you for work. I will try to undestand you code block
Vikram, please see attach
The script is still not perfect,
hands more accuratelyNumbers_sort_3bowls
I corrected handmade sort
It is ideal result
How can we do it algorithm ?
Numbers_manual sort
how to assemble one bowl 1/3 sum ? may be this answer?
Other than a brute force approach, which feels very inefficient, I cannot think of a better way right now.
Don’t think 1/3 sum in a bowl is the answer as the result will still depends on the sequence in which the numbers are considered.
I think this is a good discussion of a similar problem:
the problem is called PARTITION
I have done here v0.1
Does not work with some lists of numbers, I do not know why this is happening,
but the overall result is good