Posted 12 November 2016 - 06:44 PM
Okay, I don't really want to be spoonfed because I know that's not how this community works (neither would I learn anything from it) so I would like to work "together" with you in order to get a general idea of the "flow" I need to implement to get everything working.
The problem/task given is something like this: There is a stream of numbers (length not known). The program can fetch numbers, one at a time, and is allowed to store the numbers in 10 variables. The program can add the numbers from one of these variables to an "output" (doing that will "reset" the temp variable); when it does that the variable should be refilled with a new number (unless the stream/list is exhausted) immediately. Once the output reaches a specific number it can be emptied; the limitations are: the best case is that the output is exactly 20, it may never be below 20 but above is "acceptable" as long as it will happen as few times as possible. When the program finished executing everything should be "empty". The stream, every temp variable, and the output should contain no numbers.
I got a naive version of this working (written in Ruby) which only checks if a permutation of the temp variables equals 20 and then adds all the given temp vars to the output. Problems with this solution are for example that a long stream of 1s would break my script because after filling 10 vars with 1 it won't find a permutation whose sum is 20.
Is there anyone with any ideas?
Every help is appreciated,
~H4X0RZ
The problem/task given is something like this: There is a stream of numbers (length not known). The program can fetch numbers, one at a time, and is allowed to store the numbers in 10 variables. The program can add the numbers from one of these variables to an "output" (doing that will "reset" the temp variable); when it does that the variable should be refilled with a new number (unless the stream/list is exhausted) immediately. Once the output reaches a specific number it can be emptied; the limitations are: the best case is that the output is exactly 20, it may never be below 20 but above is "acceptable" as long as it will happen as few times as possible. When the program finished executing everything should be "empty". The stream, every temp variable, and the output should contain no numbers.
I got a naive version of this working (written in Ruby) which only checks if a permutation of the temp variables equals 20 and then adds all the given temp vars to the output. Problems with this solution are for example that a long stream of 1s would break my script because after filling 10 vars with 1 it won't find a permutation whose sum is 20.
Is there anyone with any ideas?
Every help is appreciated,
~H4X0RZ