There are a few numbers. How can you sort them into 3 bowls?


#1

there are a few numbers,
How can you sort them into 3 bowls that amount was close to each other? (equal)


#2

I may not have a solution, but, by amount do you mean sum or count?


#3

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

 


#4

Anton - See if this works for you.

File: 3bowls.dyn

20150731-1

 


#5

This sounds like a case for the “LoopWhile” node. A little messy but it should at least give you an idea:

2015-07-31_10-41-28


#6

Vikram, Dimitar, Thanks guys!
Vikram algorithm more accurate and fast!


#7

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

20150731-2


#8

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


#9

I corrected handmade sort

It is ideal result

How can we do it algorithm ?

Numbers_manual sort


#10

how to assemble one bowl 1/3 sum ? may be this answer?


#11

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.


#12

I think this is a good discussion of a similar problem:

the problem is called PARTITION


#13

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