Two numbers are consecutive between 1 and 10.
If Alex or Sam were told 1 or 10, then they would know the other number, as they would be just 2 or 9 respectively. Hence, the numbers they are told are from : 2,3,4,5,6,7,8,9 .
Suppose Alex had 2.. then Sam could be having 1 or 3... Sam had replied that he did not know what Alex had "either"... If Sam had 1, then he would know what Alex had. So Sam would have 3 in that case. One possible solution is Alex = 2, Sam = 3)
Similarly, (9, 8) pair is possible. As, the person who is told 9, will guess that the other has 8, after the 2nd line of conversation.
Suppose, Alex had 3, then Sam may have 2 or 4.. If Sam had 2, then he would know at the end of the second line of conversation that Alex had 3. But he said, he did not know "either".. It means Sam could have only 4. Thus Alex = 3, Sam = 4. is another possible solution.
Similarly, if Alex had 8, then Sam could possess 9,, in which case Sam would claim that Alex had 8.. But Sam did not know "either". So Sam did not possess 9. So sam could have only 7.
So (Alex 8, Sam 7) is another solution.
If Alex is told 4, 5, 6, 7 then he would not know even at the end of the conversation. But in our conversation, Alex knew the solution at the end. Hence, the above mentioned 4 solutions are applicable.
That is the teach told Alex and Sam: (2, 3) , (3,4) (8, 7) or (9,8) repectively.
For other combinations not involving 1 or 10, it is not possible for Alex to Guess at the end of the conversation.