You are not logged in.
Pages: 1
Hi Chaps,
When I said 'unordered' originally I meant unordered in the sense of unordered - not arranged in order hierarchically. Perhaps I should have said "unsorted"?
I'm not sure what you mean by consecutive? If by that you mean that the numbers to add up to 666 must be consecutive in the list then that is not the case, it could be that the solution is the 1st, 2nd, 5th, 8th.... nth value.
I can program in perl and have considered how I could write this using recursive loops in perl but it seems to me that for a set of 100 values I could end up with a huge number of iterations which would take ages, which is why I was hoping there might be a mathematical solution.
Do you program?
A little, if there's an algorithm which will do it I'll have a go, thanks.
You must keep the ordering given too?
yes.
For the record here's a sample list, the numbers will either be whole numbers or halves there will be no other fractions, oh and there may be occasions where it's not possible to find a set of values that will add up to the given sum:
30
20
22.5
15.0
25.0
17.5
17.5
20.0
15.0
22.5
20
20.0
37.5
32.5
12.5
22.5
20.0
20
30
25
12
15.0
22.5
17.5
15.0
17.5
20
22.5
22.5
20
21.5
25
27.5
15.0
22.5
12.5
15.0
30.0
15
30.0
27.0
20
15
12.5
17.5
33.0
22.5
17.5
15.0
20
20
17.5
15.0
22.5
17.5
17.5
17.5
10
27.0
15.0
15.0
22.5
15.0
15.0
12.5
17.5
15.0
15
15.0
25.0
24.0
25.0
15.0
22.5
20
24.0
27.0
22.5
15.0
15.0
15.0
35
17.5
27.0
20.0
15.0
15.0
30
25.0
12.5
21.0
30
20
18.0
27.5
15.0
24.0
10
17.5
11.5
The list will change depending on when I run it, so I was hoping for an 'any case' method.
I have a real world problem, and I'm hoping there will be an elegant mathematical solution to this.
I have an unordered list of ~100 values, some of which may appear more than once in the list e.g 10,15,15,12,13,10,15,29,30,.....
and I want to find the smallest number of those values, in the order given, which will add up to a particular sum, e.g. 666
Can it be done?
Thanks in advance for any help.
M:
Pages: 1