My issue
In the given test cases , for very first test, 1 as input , the answer is 1 as output , similarly in my code , for t = 1 , n =1 , output is showing 1 , but the judge is showing there is no expected output for this problem as there can be multiple correct outputs.
My code
for i in range(int(input())):
n = int(input())
i = 0
while(n):
if n%2 == 0 :
i= not i
n/=2
else:
break
print(0 if i else 1)
Learning course: Prepare for your DSA interviews
Problem Link: CodeChef: Practical coding for everyone
@codingninja_x
your logic is not right .
don’t use debug your code for this problem .
Your code is failing for some else case.
plzz refer the following python code for better understanding
T = int(input())
def lucky(N):
count = 0
while N % 2 == 0:
N = N//2
count += 1
return 1 - (count % 2)
for t in range(T):
N = int(input())
print(lucky(N))
@dpcoder_007
After thoroughly comparing the codes ,
The only place our code differs is :
Your code : counts the number of times 2’s power is there and returning the answer by taking 1-count%2.
My Code : flips the bit based on the count of 2’s power in the number N .
Edge case which i can think of only here is 1 which is getting covered in both your code and my code.
I saw and ran the code for input 1 to 10 for both of ours code , still the resultant is same in each case.
All I want is a test case where my logic is getting wrong. It’s fine if it’s against the policy then you can mention so , but still I am not able to figure out what’s the difference in logic apart from the one i mentioned above.