PROJECT EULER · #0963
Removing Trits
NOTE: This problem is related to Problem 882. It is recommended to solve that problem before doing this one.
Two players are playing a game. When the game starts, each player holds a paper with two positive integers written on it.
They make moves in turn. At a player's turn, the player can do one of the following:
- pick a number on the player's own paper and change it by removing a
from its ternary expansionbase- expansion; - pick a number on the opponent's paper and change it by removing a
from its ternary expansion; - pick a number on either paper and change it by removing a
from its ternary expansion.
The player that is unable to make a move loses.
Leading zeros are not allowed in any ternary expansion; in particular nobody can make a move on the number
An initial setting is called fair if whichever player moves first will lose the game if both play optimally.
For example, if initially the integers on the paper of the first player are
Note that the order of the two integers on a paper does not matter, but the order of the two papers matter.
Thus
Let
For example,
Find
Write-up coming later
The complete problem is available here. An approach, code, and answer will be added later.