# Perfect solution for a multiplication game

So I have encountered a question that I am struggling to figure out, what exactly would be considered a perfect way to play a game, especially when this game consists of two players. Its part of Python function that I'm suppose to make.

Question: Jacob and Vicky play the fun game of multiplication by multiplying an integer p by one of the numbers 2 to 9. Jacob always starts with p = 1, does his multiplication, then Vicky multiplies the number, then Jacob and so on. The winner is who first reaches p >= n (when n is a number chosen at the beginning of each game n>1). Assuming that both of them play perfectly (i.e. Jacob and Vicky play to win, and follow the perfect strategy to win ). Write a Python function play_fun_game, that consume a positive integer n and produces True if Vicky wins after playing the game according to the explained rules, otherwise the function produces False.

These are some of examples for this question.

play_fun_game(17) => True

play_fun_game(35) => False

play_fun_game(190) => True

play_fun_game(771) => False

play_fun_game(20) => False

play_fun_game(3480) => True

play_fun_game(1589) => False

play_fun_game(5768) => True

play_fun_game(36) => False

play_fun_game(2222) => False

play_fun_game(3489) => True

I can understand the smaller numbers like 17 and 20. If Jacob starts at 1 and can only get 2 to 9, then the other player can just get 18 (2 x 9) which is greater than 17. So if the number is 17, Vicky automatically wins, but its a lot harder to find out the winner when the numbers get bigger. I had an idea that each player would multiple by the smallest number (2) until a window of opportunity appears but that doesn't seem right as the tests don't turn out to be the same. Please help if possible.

Jacob wins if $$n\leq9,$$ Vicky wins if $$10\leq n\leq 18,$$ Jacob wins if $$19\leq n\leq 162,$$ Vicky wins if $$163\leq n\leq 324,$$ Jacob wins if $$325\leq n\leq 2916,$$ etc.
• @DaenerysTargaryen If $19\leq n\leq 81$ Jacob will choose $\left\lfloor\dfrac {n - 1} {9} \right \rfloor$ first. If $82\leq n\leq 162$ Jacob will choose $9.$ Whatever number Vicky chooses, Jacob will win. Commented Jun 14, 2015 at 20:04
• @DaenerysTargaryen above $162,$ Vicky will choose $\left\lfloor\dfrac {n - 1} {J_1\cdot 9} \right \rfloor$, where $J_1=$ Jason's first choice, etc. Commented Jun 14, 2015 at 20:30