random walk with sticky barriers Consider a random walk on the line 1,...,d.  You start at point 1.
At each step you flip a coin: heads means go left, tails means
go right. If you're at 1 and get a heads, just stay where you are (same if
you're at d and get a tails). Also known as random walk with reflective barriers.
P(x,y) = 1/2 |x-y|=1 or x=y=1 or x=y=d and
       =0 otherwise
Trying to get an expression for mean number of steps to reach d given that you start in 1, using conditioning on next move. 
I tried this but not sure if its correct. Let Sx be the expected number of steps need to go to x+1 given that you start in x. S0=1, Sx=(1/2) + (1/2) Sx-1 + (1/2) Sx and so,
Sx = 1+ Sx-1
 A: Let $p_x^+$ be the probability of moving $x \to x+1$, $~p_x^-$ be the probability of moving $x \to  x-1$, and $p_x^0$ be the probability of moving $x \to x$. If $\tau$ is the number of steps until you first hit $d$ and $s_x := E_x(\tau)$ is the expected number of steps until you first hit $d$ starting at $x$, then $$s_x = (1 + s_{x+1})p_x^+ + (1 + s_{x-1})p_x^- + (1+s_x)p_x^0 = 1 + p_x^+ s_{x+1} + p_x^- s_{x-1} + p_x^0 s_x$$
Now:
$$
s_1 = 1 + \tfrac{1}{2}s_2 + \tfrac{1}{2} s_1 \implies s_2 = s_1 - 2\\
s_2 = 1 + \tfrac{1}{2}s_3 + \tfrac{1}{2}s_1 \implies \tfrac{1}{2} s_1 = 3 + \tfrac{1}{2} s_3 \implies s_3 = s_1 - 6\\
s_3 = 1 + \tfrac{1}{2}s_4 + \tfrac{1}{2}s_2 \implies s_1-6 = 1 + \tfrac{1}{2}s_4 + \tfrac{1}{2}(s_1 - 2) \implies s_4 = s_1 - 12\\
s_4 = 1 + \tfrac{1}{2}s_3 + \tfrac{1}{2} s_5 \implies s_1 - 12 = 1 + \tfrac{1}{2}(s_1 - 6) + \tfrac{1}{2}s_5 \implies s_5 = s_1 - 20 \\
\vdots\\ 
$$
Continuing this way, you'll find an expression of the form $s_d = s_1 - ?$; from the definition of $s_x$ you should know what $s_d$ is without any work. You'll then have $s_1 = s_d + ?$ which is what you're looking for. As a hint to find $?$ note that if we let $a_2, a_3, ..., a_d$ be the sequence such that $s_n = s_1 - a_n$ then for each $2< n < d$ you have 
$$
s_1 - a_n = s_n = 1 + \tfrac{1}{2}s_{n-1} + \tfrac{1}{2}s_{n+1} = 1 + \tfrac{1}{2}(s_1 - a_{n-1}) + \tfrac{1}{2}(s_1 - a_{n+1}) \\
\implies a_{n+1} = 2 + 2a_n - a_{n-1}
$$
and we've already found that $a_2 = 2$ and $a_3 = 6$, so you can use the recursive formula to solve for $a_d$.

Added Hint: To find a closed formula for the $a_n$, notice that you can rearrange the recursive formula to 
$$
a_{n+1}-a_n = 2 + a_n - a_{n-1}
$$
Now, we will use a telescoping series argument. Sum this equation from $n=3$ to $n = N-1$ (where $4 \leq N \leq d$ is arbitrary); on the lefthand side you will get $a_N - a_3$; on the righthand side you will get $2(N-3) + a_{N-1} - a_2$. Once you do this, you can rearrange the resulting equality to 
$$
a_N - a_{N-1} = 2(N-3) - a_2 + a_3 = 2(N-3) - 2 + 6 = 2(N-1)
$$
To finish, do the same argument again (telescoping series) with this last equation summing from $N=4$ to $N=d$, then on the lefthand side you will get $a_d - a_3$ and on the righthand side you get ...? Finish from here and solve for $a_d$.
