Sha256: 17fc33fda01a580182c5f248055a0058341f9ed6173412d2b1cf2880f563d895

Contents?: true

Size: 1.72 KB

Versions: 255

Compression:

Stored size: 1.72 KB

Contents

'use strict';
var Palindromes = require('./palindrome-products');

describe('Palindrome', function() {

  it('largest palindrome from single digit factors', function() {
    var palindromes = new Palindromes({maxFactor: 9});
    palindromes.generate();

    var largest = palindromes.largest();
    expect(largest.value).toEqual(9);
    var orderedLargestFactors = largest.factors.sort(
      function(a, b) { return a[0] > b[0]; }
    );
    expect(orderedLargestFactors).toEqual([[1, 9], [3, 3]]);
  });

  xit('largest palindrome from double digit factors', function() {
    var palindromes = new Palindromes({ maxFactor: 99, minFactor: 10 });
    palindromes.generate();

    var largest = palindromes.largest();
    expect(largest.value).toEqual(9009);
    expect(largest.factors).toEqual([[91, 99]]);
  });

  xit('smallest palindrome from double digit factors', function() {
    var palindromes = new Palindromes({ maxFactor: 99, minFactor: 10 });
    palindromes.generate();

    var smallest = palindromes.smallest();
    expect(smallest.value).toEqual(121);
    expect(smallest.factors).toEqual([[11, 11]]);
  });

  xit('largest palindrome from triple digit factors', function() {
    var palindromes = new Palindromes({ maxFactor: 999, minFactor: 100 });
    palindromes.generate();

    var largest = palindromes.largest();
    expect(largest.value).toEqual(906609);
    expect(largest.factors).toEqual([[913, 993]]);
  });

  xit('smallest palindrome from triple digit factors', function() {
    var palindromes = new Palindromes({ maxFactor: 999, minFactor: 100 });
    palindromes.generate();

    var smallest = palindromes.smallest();
    expect(smallest.value).toEqual(10201);
    expect(smallest.factors).toEqual([[101, 101]]);
  });

});

Version data entries

255 entries across 255 versions & 1 rubygems

Version Path
trackler-2.2.0.4 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.0.3 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.0.2 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.0.1 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.0.0 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.55 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.54 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.53 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.52 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.51 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.50 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.49 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.48 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.47 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.46 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.45 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.44 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.43 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.42 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.1.0.41 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js