I've been trying to find the minimum steps it takes for a number to be reduced to 1 given the three following steps:Divide by 2Increment by 1Decrease by 1My code is as follows:def answer(n):    num = long(n)    count = 0    while num > 1:        #When number is odd        if num%2 == 1:        #If the number obtained by increment is odd, don't increment. Instead decrease             if ((num+1)/2)%2 == 1:                count += 1                num -= 1            else:                num += 1                count += 1        num /= 2        count += 1    return int(count)Let me know if there's a better way to solve this problem.
Test case where code fails
python