In a question I should deal with long inputs given as binaries. Like
"1000101011111101010100100101010101010101"
I am required to use the bitwise opertator OR |
in this question. I have researched the use of this operator and it seems to work on regular integers not binaries. So I call int(thing, 2)
on it. After that, I use the bitwise operator. However something troubles me. Isn't the python interpreter changes it back to binary again to apply Bitwise OR on it ? So isn't it seems like a repeated step ?
Is there no other way to directly use this string, maybe an iteration over all the letters is a better approach ? There is also another problem that about integer precision. Because sometimes the input is larger than 500 characters so I can't store it as an integer.
I tried something like this, Imagine a
and b
are two binary strings.
for comparison in zip(a, b):
if any(comparison):
# Do stuff if OR gives 1
This is proven to be very slow indeed. Please enlighten me.
Thanks in advance.