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.139 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.138 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.137 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.136 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.135 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.134 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.133 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.132 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.131 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.130 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.129 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.128 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.127 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.126 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.125 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.124 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.123 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.122 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.121 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.120 tracks/javascript/exercises/hamming/example.js