Sha256: 016d096b8d3b70ece23d661d53d9951c73c7d3636e724394e19e8abc7992d01f

Contents?: true

Size: 371 Bytes

Versions: 240

Compression:

Stored size: 371 Bytes

Contents

function Hamming() {}

Hamming.prototype.compute = function (strand1, strand2) {
  if (strand1.length !== strand2.length) {
    throw new Error('DNA strands must be of equal length.');
  }

  var distance = 0;

  for (var i = 0; i < strand1.length; i++) {
    if (strand1[i] !== strand2[i]) {
      distance++;
    }
  }

  return distance;
};

module.exports = Hamming;

Version data entries

240 entries across 240 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.179 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.178 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.177 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.176 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.175 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.174 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.173 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.172 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.171 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.170 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.169 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.167 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.166 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.165 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.164 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.163 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.162 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.161 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.160 tracks/javascript/exercises/hamming/example.js