Sha256: f618f4f9710ad0fb300e0ba62e90510fc00b317ff33ace047c67bcfbf5b66e5b

Contents?: true

Size: 1.72 KB

Versions: 141

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

141 entries across 141 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.118 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.117 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.116 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.115 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.114 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.113 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.111 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.110 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.109 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.108 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.107 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.106 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.105 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.104 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.103 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.102 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.101 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.100 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js
trackler-2.2.1.99 tracks/javascript/exercises/palindrome-products/palindrome-products.spec.js