2
$\begingroup$

I have a sequence of motions from images and I need to store all these values. For example:

  • a) 1, 2, 3, 4, 3, 2, 1
  • b) 1, 2, 3, 2, 3, 4, 5, 4, 3, 2, 1

In order to save space, it would be necessary to have some function that could generate unique numbers to represent each of these sequences. But also, there is another problem: I need representations which could be compared, so, suppose I have

  • a) 1, 2, 3, 4, 4, 3, 2, 1
  • b) 1, 2, 3, 4, 3, 2, 1

The motion in a) is very similar to b), so I would need some way to represent similarity. There is two patterns for increment/decrement in these sequences, either by 1 or 0, or any other integer value.

I am starting to read about pairing functions and some other similar topics here but I am not sure if I can apply for this (like this topic).

  • 1
    I notice that in your examples, the differences are $1$, $0$, or $-1$. Is that always the case? Is the length of these sequences bounded?2012-04-01
  • 0
    Consider $1, 2, 3, 4, 4, 3, 2, 1.$ (resp. $1, 2, 3, 4, 3, 2, 1.$) You only need to know length $8$ (resp. $7.$) The sequences is $1, 2, \ldots, i-1, i, j, j-1, j-2,\ldots 2, 1.$ If length $= n$ is odd, then $i = 1 + \lfloor n/2 \rfloor$ and $j = i+1.$ If length $= n$ is even, then $i = j = n/2.$ Only store $n.$2012-04-01
  • 0
    @Lubin Edited the question, thanks.2012-04-01

2 Answers 2