Create a program that computes the hamming weight of a string. Winner is the program with the lowest hamming weight.
- Hamming weight for an ASCII character is defined as the total number of bits set to
1in its binary representation.
- Assume input encoding is 7-bit ASCII, passed through whatever input mechanism is normal for your language (e.g. stdin, args, etc.)
- Output the result, as a number, to stdout or whatever default/normal output mechanism your language uses.
- It should go without saying, but you have to be able to actually run the program, in real life, for it to be a valid solution.
- Winner is the solution whose code has the lowest hamming weight.
Sorry, no solutions in whitespace for this one!Ok, you can code in whitespace now I've sorted out the rules :)
char | binary | weight -----+----------+------- a | 01100001 | 3 x | 01111000 | 4 ? | 00111111 | 6 \x00 | 00000000 | 0 \x7F | 01111111 | 7