Solution to exercism.io ruby hamming problem