Sha256: 0ef04c98e6afba7fcc51d868057a743b32aea3464caa949e1f2fbac2426ef4d6

Contents?: true

Size: 416 Bytes

Versions: 156

Compression:

Stored size: 416 Bytes

Contents

function Hamming() {}

Hamming.prototype.compute = function (strand1, strand2) {
  var len1 = strand1.length;
  var len2 = strand2.length;

  if (len1 !== len2) {
    throw new Error('DNA strands must be of equal length.');
  }

  var out = -0;
  var idx = -1;
  var end = Math.max(len1, len2);

  while (++idx < end) {
    if (strand1[idx] !== strand2[idx]) out++;
  }

  return out;
};

module.exports = Hamming;

Version data entries

156 entries across 156 versions & 1 rubygems

Version Path
trackler-2.1.0.0 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.55 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.54 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.53 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.52 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.51 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.50 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.49 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.48 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.47 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.46 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.45 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.44 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.43 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.42 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.41 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.40 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.39 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.38 tracks/javascript/exercises/hamming/example.js
trackler-2.0.8.37 tracks/javascript/exercises/hamming/example.js