Finding new arrangement, according to restrictions I'm not sure what topic in math this is (probably Graph Theory), but maybe you can help me. 
The Challenge
My task is like this: I have to create an automatic program that will assign each student in a class (of variable size, but my own class now has 11 students) a reviewer for his assignment, according to a set of rules:


*

*The students sit in a row

*One cannot review himself

*Two students cannot review each other (reciprocally)

*One cannot review his neighbor (from both sides)

*One cannot review the student he reviewed the last time


And the real trouble maker: 


*

*One cannot review the student he reviewed two times before


The programming implementation of this problem is not important – though so far the logic and algorithms that I've tried to implement have all failed (i.e. reaching a dead-end, or in the case of my programs, an infinite loop).
My previous approaches
At first I tried to simply throw a random number between 1 and the class size (11), check if it follows the rules (updating the availability of each student as we go, of course), and if so assigning that student as a reviewer. I found out very quickly that it often gets stuck on the last student, because the random assignments done prior leave the last student with no available reviewers according to the rules. 
So this reminded me of the problem of coloring the map of the US states with 4 colors, and I tried another approach where before each assignment the program checks if that assignment will leave another student without any available reviewers – and only if it doesn't it assigns the reviewer, otherwise it looks for another random reviewer. 
And this worked for 2 to 3 times, until it ALSO GOT STUCK (!!) And the reason is that it came into a situation where, say, after assigning 8 students, student 9 had two possibilities, and choosing 1 of them would leave student 10 with no available students while choosing the other would leave student 11 without one…
I didn't want to go up two levels and solve this problem, because it seemed I'm just pushing the problem one level higher each time. So I went for another approach:

Before each assignment check for the students with the least number of possible reviewers, and assign to him/her first. (Though I didn't implement it, you could probably still make it random after adding the rule that if there is more than one student who has the lowest number, choose one of them randomly.)

This worked for about 10 times, until… you guessed it, it also got stuck. And for the last student there was no reviewer left which abided by the restrictions.
What I'm Looking For


*

*Well, an algorithm which will solve my problem; 


or


*A proof that shows it cannot be done, i.e. that you cannot guarantee you would not get stuck at some point (at least not with 11 students and checking 2 times back);


or at the very least


*Some help of finding relevant material that can advance me in my quest for the holy grail. 


NOTE: When checking only 1 time back, I didn't encounter any problem, though I'm not sure if this means that you can't encounter any dead-ends, or that it's just rarer to encounter them. 
Big Note
I think there's an easy way, where you just assign each student the first available option, and rotate everyone exactly the same. 
i.e.:
    1 2 3 4 5 6 7 8 9 . ..
1   m 0 l s 1 1 1 1 1 1 1
2   0 m 0 l s 1 1 1 1 1 1
3   1 0 m 0 l s 1 1 1 1 1
4   1 1 0 m 0 l s 1 1 1 1
5   1 1 1 0 m 0 l s 1 1 1
6   1 1 1 1 0 m 0 l s 1 1
7   1 1 1 1 1 0 m 0 l s 1
8   1 1 1 1 1 1 0 m 0 l s
9   s 1 1 1 1 1 1 0 m 0 l
10  l s 1 1 1 1 1 1 0 m 0
11  1 l s 1 1 1 1 1 1 0 m

(m - self, l - last review , s - second last, 1 - available option, 0 - not available)
so, for the first student you choose number 5, for the 2nd you choose 6, etc. And the next time you rotate everyone one position.
It guess this will work, but I'm looking for a solution that doesn't require such a tidy arrangement of the students. Also – this is not random at all – it will be a series of (in this case) 8 other reviewers that each student will traverse, and it will keep repeating itself. I would prefer a more random assignment.
Though if you can show this is the only/best way, that would be good enough for me. 
Thanks,
David
 A: Here's a direction,
Let me know (in the comments) if this directions appeals to you.
Your question can be translated into the following: 
Let $A$ be the set of permutations $\pi\in S_{11}$ such that:


*

*$\pi$ has no fixed points.

*$\pi(k)\neq k+1$ and $\pi(k)\neq k-1$ (for all $k\in\{1,\dots,11\}$).

*$\pi$ has no $2$-cycles (transpositions) in cycle notation.


Given a finite sequence $S=(\pi_1,\dots,\pi_t)$ of permutations in $A$, say that $S$ holds the 2-history condition if for every $\pi_i$ in $S$,  $\pi_i^{-1}\circ\pi_{i-1}$ (for $i>1$) and $\pi_1^{-1}\circ\pi_{i-2}$ (for $i>2$) have no fixed points.
A good finite sequence $S$ of permutations in $A$ is one holding the 2-history condition and for which there is some permutation $\pi\in A$ that can be appended to $S$, denoted $S*\pi$, such that $S*\pi$ also holds the 2-history condition.
An ideal solution for your question would be if there exists an an algorithm that given a good sequence $S$ produces a (random) good sequence $S*\pi$ for some $\pi\in A$. You will then only need to produce a (random) good triplet to start with.
(TBD: Given a good triplet $S$ identify the sequences $S*\pi$ that are not good; prove that they can be avoided (i.e. every good finite sequence can be extended to an infinite one); add randomness).
