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

**URL:** <https://forum.inductiveautomation.com/t/solved-looking-for-the-algorithm-equivalent-of-this-lookup-table/37087>\
**Category:** General Discussion\
**Created:** [July 25, 2020, 4:09pm UTC](https://forum.inductiveautomation.com/t/solved-looking-for-the-algorithm-equivalent-of-this-lookup-table/37087 "2020-07-25T16:09:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [July 25, 2020, 4:09pm UTC](https://forum.inductiveautomation.com/t/solved-looking-for-the-algorithm-equivalent-of-this-lookup-table/37087/1 "2020-07-25T16:09:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BenKearney](https://avatars.discourse-cdn.com/v4/letter/b/b19c9b/32.png) [@BenKearney](https://forum.inductiveautomation.com/u/BenKearney)\
**Post date:** [July 25, 2020, 4:41pm UTC](https://forum.inductiveautomation.com/t/solved-looking-for-the-algorithm-equivalent-of-this-lookup-table/37087/2 "2020-07-25T16:41:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [July 25, 2020, 5:04pm UTC](https://forum.inductiveautomation.com/t/solved-looking-for-the-algorithm-equivalent-of-this-lookup-table/37087/3 "2020-07-25T17:04:05Z")

</div>

Thank you very much. You make it look easy 😅
