I have some "centering" rules that involve a calculation using a count and index. Both count and index are between 1 and 5. The goal is to center a set of items around a given starting point ( in this case -12 ).
The returned value is determined as follows, by looking up the count and then the index:
{
count: {
index: value
}
}
If I represent all possible values as a dictionary (in python) it looks like this:
{
1: {
5: -12
},
2: {
5: -21,
4: -3
},
3: {
5: -30,
4: -12,
3: 6
},
4: {
5: -39,
4: -21,
3: -3,
2: 15
},
5: {
5: -48,
4: -30,
3: -12,
2: 6,
1: 24
}
}
What kind of formula can express these relationships? I can see a clear difference of 18 between each value in a given series, but I'm having trouble with the odd/even difference.
Since when
countis increased, the value gets reduced by 9,and when
indexis increased, the value gets reduced by 18, we obtain a function of the form:$$f(count, index) = c - 9^*count - 18^*index$$
where $c$ is to be determined. Substituting $count=index=3$ (or any other value):
$$f(3,3) = c-81=6 \implies c=87$$
Hence your function would be:
$$f(count,index) = 87-9^*count-18^*index$$