(no title)
arnioxux | 5 years ago
OTOH as a programming problem you can just cheat and store state somewhere to count the row width. This satisfies your interface requirements (python):
lastJ = None
def f(i, j):
global lastJ
if i != 0:
return i * (lastJ + 1) + j
else:
lastJ = j
return j
N = 3
M = 5
seen = set()
for i in range(N):
for j in range(M):
q = f(i, j)
seen.add(q)
assert sorted(seen) == list(range(N * M))
pinopinopino|5 years ago
I think it isn't possible to find a function that works for arbitrary sequences. I know there is a function that works if the sets have the same size (n is size), it is trivial why those work. They have the form n^0 a + n^1 b, where a,b are in [1..n]:
Now I want to find functions like (n,m is size, n /= m): And functions where n maybe chosen but m is between certain bounds. I have found a couple of those by mutilating pairing functions.I know I can use a counter, but I don't like cheating :p
I need to draw your reasoning on a paper to see it or take some time for it. Little bit busy, working from home, having the kids and stuff :p
pinopinopino|5 years ago