probability of sequence of integers Suppose you have numbers from 1 to 10. You can choose four of them but the contiguous numbers should have an absolute difference greater than 1. For example, you can choose
$$ 1-3-6-10$$
$$ 4-2-5-1$$
but you cannot choose
$$ 1-2-4-8$$
$$ 4-1-3-2$$
What is the probability that you choose an admissible sequence? 
I could not solve it mathematically so I wrote a short code in R

require(gtools)
x=permutations(10 ,4)
y = abs(apply(x,1,diff))
cf = function(x){
  is.element(1,x)
}
z=apply(y,2,cf)
x[z==F,]
sum(z==F)/(dim(x)[1])

If I am not mistaken, you can choose an admissible sequence with $0.4861111$ probability. Can you show it mathematically?
 A: I did it in excel.  The entries are the number of acceptable strings of length 1 through 4 ending in the number on the left.  $$\begin {array} {c c c c c c}1&1&8&57&413\\2&1&7&50&362\\3&1&7&51&368\\4&1&7&51&367\\5&1&7&51&367\\6&1&7&51&367\\7&1&7&51&367\\8&1&7&51&368\\9&1&7&50&362\\10&1&8&57&413\\&&&&3754\end {array}$$  The total is $3754$ out of $10000$ for a chance of $0.3754$
A: Another approach to the count: Form the $10 \times 10$ transition matrix $M$ where $m_{i,j}=0$ when $|i-j|<2$, and otherwise $m_{i,j}=1.$ Then the matrix $N=M^3$ has its $(i,j)$ entry as the count of the number of allowable strings of length 4 which begin with $i$ and end with $j$. (This assumes as in Ross' answer above that repetitions are allowed, e.g. the string 2-4-2-5 is OK).
So the sum of all the elements of $M^3$ gives the total number of allowable strings of length 4. To extract the sum one can pre and postmultiply by a row, respectively column, matrix of all 1's. This gives the grand total of 3754 in agreement with Ross' answer.
I've tried to modify this method to count the number of strings in which repetitions are not allowed. That so far eludes me, though I have some ideas.
EDIT: I found a way to do the count with repetitions not allowed. We start with the number $3754$ which counts with repetitions allowed and subtract from this the possible cases which have repetitions. There are four types of repetitions. The easiest to count is the form $(a,x,y,a)$ which is obtained by adding up the diagonal elements of $M^3$. (Since $a$ occurs on either end, and the transition matrix bars any transitions to adjacent elements, this count is OK). There are then $336$ strings of type $a,x,y,a$.
The other types of repetition naturally group into three types: a type $(a,x,a,y),$ another type $(x,a,y,a)$ with the same count as $(a,x,a,y)$ by symmetry, and the overlap of these two types which is $(a,b,a,b)$ whose count must be added back in since it got double counted. For the type $(a,x,a,y)$ we form the row matrix of the diagonal elements of $M^2$ and multiply that by $M$, and sum the ten entries, giving $520$ repeats of type $(a,x,a,y).$ Then there's another $520$ of type $(x,a,y,a)$ as noted by symmetry. Finally the number of double counted strings $(a,b,a,b)$ is just the sum of the elements of $M$ which is $72.$
So the calculation is 
$$3754-336-520-520+72=2450.$$
That is, the total number of allowable strings, in the sense of all adjacent terms at least at distance $2$ apart, and no repeated entries, is exactly $2450.$ If one uses the sample space of all strings of length four without repeats, i.e $10 \cdot 9 \cdot 8 \cdot 7,$ one obtains for the probability the number
$$p=\frac{2450}{5040}=\frac{35}{72}=0.486111\cdots,$$
which matches the answer obtained by the OP's program.
