I am struggling with a problem – please forgive me for my bad English. I am currently writing some script in Python where I need to manipulate list and convert them.
I want to convert a double numbering to another numbering where only one index is used.
If n is the first index of my double numbering and m the second one, what is the expression L(n, m) = idx which permits to pass from (here n_max = 3 but I want a general rule) :
[n, m] => [[0, 0], [1, 0], [2, 0], [3, 0], [1, 1], [2, 1], [3, 1], [2, 2], [3, 2], [3, 3]]
and so on to
idx => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
? It clearly depend on n_max but I am searching for a while and don’t find any reliable expression or script.
For example, if the [n, m] had the following structure :
[[0, 0], [1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2], [3, 3]]
the searched expression would be :
idx = L(n, m) = n * (n + 1) / 2 + m
Any help will be appreciated, even little hints or links 🙂
Thanks ! I already searched on the web and on this website but didn’t find any answer.
Found it.
It was the following: