Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
XOR solution in Clear category for [old] The Hamming Distance by asdufersal
"use strict";
let hammingDistance = (n, m) => (n^m).toString(2).split('').filter(x=>x>0).length
var assert = require('assert');
if (!global.is_checking) {
assert.equal(hammingDistance(117, 17), 3, "First example");
assert.equal(hammingDistance(1, 2), 2, "Second example");
assert.equal(hammingDistance(16, 15), 5, "Third example");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
April 9, 2019