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.159 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.158 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.157 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.156 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.155 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.154 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.153 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.152 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.151 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.150 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.149 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.148 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.147 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.146 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.145 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.144 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.143 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.142 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.141 tracks/javascript/exercises/hamming/example.js
trackler-2.2.1.140 tracks/javascript/exercises/hamming/example.js