python,string,bitmap,bitstring

This took me a while to figure out, as your solution seems to ignore the first bit of data. Given the input byte of 129 (0b10000001) I would expect to see 64 '1000000' printed by the following, but your code produces 1 '0000001' -- ignoring the first bit. bs =...

Here is a linear solution to this problem: Let's compute prefix function for the given string(like in Knuth-Morris-Pratt's algorithm). The answer is always n - p[n], where n is the length of the given string and p[i] is the value of the prefix function for the i-th position in the...

python,numpy,bit-manipulation,bit,bitstring

I'm not sure if you want to count the number of "1" bits or to check wether a specific bit is set. To check, I guess the easier way is: bool(n&(1<<b)), where n is the number being tested and b is the bit (starting from 0). To count the number...

python,numpy,bitwise-operators,bitarray,bitstring

As far as I can tell, the built-in Python 3 int is the only one of the options you tested that computes the & in chunks of more than one byte at a time. (I haven't fully figured out what everything in the NumPy source for this operation does, but...