I am trying to solve a competitive coding problem. I managed to pass all the test cases except one. I am guessing that I've missed some kind of an edge case.
Problem:
Given a decimal number as input, convert it to binary and change the bits at the specified positions(given in the input) in the binary form of the number to 0. Output the resulting binary number in decimal form.
Here is my code:
import math
for _ in range(int(input())):
n = int(input()) #The given number
a = list(map(int, input().split())) #Positions at which the bits need to be masked
b = str(bin(n))[:1:-1]
for i in a:
if i<=len(b) and b[i-1]=='1':
n-=math.pow(2, i-1)
print(int(n))
If somebody could tell the possible edge cases that I might have missed, it would be great. I couldn't find any sort of discussion for this problem and it does not allow me to see other's solution. Any help is appreciated. Thanks.