[SOLVED] Looking for the algorithm equivalent of this lookup table

Good morning,

Here is a mind bender for the ambitious… I’d say it’s not that difficult but it breaks my brain to think about.

I have the following lookup table in a dataset tag. Each column is the previous column shifted by one. The first column will always start at 0 to n. There are always n columns in the table.

Col0    Col1    Col2    Col3    Col4    Col5    Col6
0       1       2       3       4       5       6
1       2       3       4       5       6       0
2       3       4       5       6       0       1
3       4       5       6       0       1       2
4       5       6       0       1       2       3
5       6       0       1       2       3       4
6       0       1       2       3       4       5

You are given two variables:
varRow == 0, 1, 2, 3, 4, 5, 6
varCol == 0, 1, 2, 3, 4, 5, 6

Calculate, using an algorithm, the lookup value from the lookup table above. The algorithm should be applicable to any similar lookup table up to n columns.

Thanks for any help.

(varRow + varCol) mod (n+1) seems to work

2 Likes

Thank you very much. You make it look easy :sweat_smile: