A game of add at most 10 This is the problem:
There are two players A and B. Player A starts and chooses a number in the range 1 to 10. Players take turn and in each step add a number in the range 1 to 10. The player who reaches 100 first wins.
In the program, player A is the user and player B is the computer. Besides that the computer must force a win whenever possible. For instance, if the player A reaches 88 at some point, the computer must choose 89, as this is the only way to force a win.
The problem i face is how do I do the forcing on the part of the computer. Need some guidance on that. 
 A: Let's assume we will add in range $1$ to $a$ ($1 \leq a$) and we want to reach $0 \leq b$. Then, you should stay on the numbers which gives ($b$ mod $a+1$) in mod $a+1$. For example, if $a = 10$ and $b = 100$, you should say $1,12,23,34,45,56,67,78,89$. So, if you start, say $1$ and whatever computer says, say $12$ (and you can do that because computer can't say $12$ but whatever it says you can say it) and go like that, win!
For example, when you said $1$, it can say only $2, 3, 4, 5, 6, 7, 8, 9, 10, 11$ and you can say $12$ in any situation, and this goes like that.
Also you might want to think about that for fun: Let's assume we can add the numbers in a set $S$, and we want to reach $x$. Is there an algorithm which gives exact solution (as like I gave in first paragraph for a special $S$) for any $S$?
A: First player starts with $1$ and then at each turn after picks $11-n$ where $n$ was the other player's choice. That means the numbers are $11k+1$ after first player's turn, and therefore you get to $89$ at turn $9$.
If first player even chooses any other value, then second player should choose so the sum is $11k+1$ for some $k$ and can force a win.
A: Consider a recursive function $f:\{0,...,100\}\to \{0,1\}$ where $f(n)=1$ if and only if the current player can win, equivalent can force his opponent to lose, when he have number $n$. $f(n)=0$ otherwise. Note that $f(100)=0$. Now for $n<100$
$$f(n)=1-min\{f(n+1),f(n+2),...,f(min(n+10,100))\},$$
so you win, $f(n)=1$, if and only if in some election from $1$ to $10$ your opponent lose. Then the best choice will be some number $i$ from $1$ to $10$ such that $f(n+i)=0$, so you will win because $f(n)=1-0=1$. In your example, when $A$ reaches $88$, the player $B$ will choice $i=1$ because $f(n+i)=f(88+1)=f(89)=0$, because player $A$ will not have choice for win with $n=89$.
