## #math trivia #62 solution

Burt Kaliski Jr. (@modulomathy)
3/2/12 9:09 PM
#math trivia for #March2: #62 is 111110 base 2; with 5 ones this is “Hamming weight” 5. What other days this year have the same “weight”?

The Hamming weight of an integer is the number of ones in its binary (base 2) representation.

To find the different ways that integers can be constructed with 5 ones, consider that the integers 1 to 366 fall into the following 9-bit binary representations, where x is either 0 or 1:
``` 0xxxxxxxx 100xxxxxx 1010xxxxx 101100xxx 1011010xx 10110110x 101101110 ```
In order for the integer to have weight 5, the right number of x bits need to be 1. For the different formats the number of bits and their integer values are as follows:
``` 0xxxxxxxx - 5 of 1, 2, 4, 8, 16, 32, 64 and 128 (56 combinations) 100xxxxxx - 4 of 1, 2, 4, 8, 16 and 32 (15 combinations) 1010xxxxx - 3 of 1, 2, 4, 8 and 16 (10 combinations) 101100xxx - 2 of 1, 2 and 4 (3 combinations) 1011010xx - 1 of 1 and 2 (2 combinations) 10110110x - no more bits set (1 combination) 101101110 - weight 6 (0 combinations) ```
The total number of integers with weight 5 is thus 87 — nearly one fourth of all days of the year have this property. The day numbers (expressed as base plus offset) are
``` 0xxxxxxxx - 31, 47, 55, 59, 61, 62, 79, 87, 91, 93, 94, 103, 107, 109, 110, 115, 117, 118, 121, 122, 124, 143, 151, 155, 157, 158, 167, 171, 173, 174, 179, 181, 182, 185, 186, 188, 199, 203, 205, 206, 211, 213, 214, 217, 218, 220, 227, 229, 230, 233, 234, 236, 241, 242, 244 and 248 100xxxxxx - 256 + 15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58 or 60 1010xxxxx - 320 + 7, 11, 13, 14, 19, 21, 22, 25, 26 or 28 101100xxx - 352 + 3, 5 or 6 1011010xx - 360 + 1 or 2 10110110x - 364 ```
I’ll leave it to the reader to add the base and offset to get the actual day numbers, and to determine the corresponding calendar dates. Which month do you think will have the most of them?