I was having a look at this stackoverflow question: Game of 2/9 (Interview at Facebook)
In one of the answers it is stated that by comparing with a recursive solution it is possible to find this algorithm:
def win29(n):
if n<=9: return True
n-=1
while n>=18:
n = n//18
return n==1 or 4<=n<=8
I guess the recursive algorithm would be this one:
F(i, j) = true; if (2^i * 9^j * 9) >= N
!(F(i+1, j) && F(i, j+1)); otherwise
What would be the mechanism or procedure (or comparison) to convert this recursive algorithm into the iterative one above?
n = n//18... orif n<=9: return Truebut in the latter code exampleF(i, j) = true; if .... Da hell?