0

I have a number of sets of data. These sets contain numbers that specify how much points a user gains upon passing to the next index:

A = (2,[2],2,6,6,10)
B = (2,4,[4],2,5,7,7,6,10,12,10,6)
C = (2,3,[4],5,6,7,7,8,10)

In this example I use three sets but in the real problem it are far more sets (a variable amount). The [square] brackets mean that that is the current selected index, so the indexes specified above are: (1,2,2) All these indexes together form a total that I can keep track of by grabbing it from a webpage (in this case the total is: (2+2)+(2+4+4)+(2+3+4) = 23). By keeping track of the total I know that the total changes with a number, let's call this number X.

Total:   23 -> 25 -> 30
X:          +2   +5       (these are the numbers X I can keep track of, they are given, but variable)  

In this example the first X is +2, this either means that A went from 1->2 or B from 2->3:

Case 1: A passes on

A = (2,2,[2],6,6,10)
B = (2,4,[4],4,5,7,7,6,10,12,10,6)
C = (2,3,[4],5,6,7,7,8,10)

Case 2: B passes on

A = (2,[2],2,6,6,10)
B = (2,4,4,[2],5,7,7,6,10,12,10,6)
C = (2,3,[4],5,6,7,7,8,10)

We know the next increase is +5, this either means that for case 1, C goes from 2 -> 3 or for case 2: B 3->4 or C 2 -> 3

Case 1: A increased => C increased

A = (2,2,[2],6,6,10)
B = (2,4,4,[2],5,7,7,6,10,12,10,6)
C = (2,3,4,[5],6,7,7,8,10)

Case 2: B increased => B increased

A = (2,[2],2,6,6,10)
B = (2,4,4,2,[5],7,7,6,10,12,10,6)
C = (2,3,[4],5,6,7,7,8,10)

Case 3: B increased => C increased

A = (2,[2],2,6,6,10)
B = (2,4,4,[2],5,7,7,6,10,12,10,6)
C = (2,3,4,[5],6,6,7,8,10)

Now what I need to write an algorithm for is to display EVERY possible combination of indexes as a result of the increases I=(+2,+5), note that it in reality these are variables: I=(+X, +Y, +Z, ...) and the depth is also variable.

Now the problem looks quite easy, but imagine the next increase being 7 resulting in I=(+2,+5,+7), then there only remains 1 case valid (B->B->B). In some way I thus need to write a big recursive function that re-evaluates all results and removes dead ends, for every following increase, but I'm not sure how to write such a function.

For extra clarification: imagine the tracked data going +2, +5, +6, +6 then this diagram shows me what I want accomplished: Tree diagram

Summary: The full problem with all its variables is thus:

N Sets of data:

A = (a1,a2,a3,a4,...)
B = (b1,b2,b3,b4,...)
...
N = (n1,n2,n3,n4,...)

A given array Z with the current selected indexes:

Z = ([A], [B], [C], ... , [N])

A given array I with increases with depth N:

I = (+X,+Y,...,+N)

Asked: possible new arrays Z (possible ways to get to the new total with given intervals using only the increases specified in the data sets)

What I want: How to write an algorithm for this purpose, I don't need you to write the algorithm, but a starting points would be nice, I'm kinda lost in the problem.

Note: due to this question being quite long and technical, it is possible that some minor mistakes got in, comment below and I'll try to solve them

JohannesB
  • 1,995
  • 21
  • 35

0 Answers0