Read an integer variable, and determine the smallest positive integer that has the same number of 1s…
Click here to read the complete problem statement.
If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.
usr = int(input())
emp = list(bin(usr))
final = []
emp.remove('b')
for i in range(len(emp)):
if emp[i] == '0':
i += 1
else:
final.append(int(emp[i]))
digit = 0
for low in range(len(final)):
digit += (final[low]*(2**low))
print(digit)