Sha256: 222eaec63ffaf80b0174264c0f259125d87d631b79b8242eceb0d60c5bfb636b

Contents?: true

Size: 1.99 KB

Versions: 141

Compression:

Stored size: 1.99 KB

Contents

var solve = require('./alphametics');

describe('Solve the alphametics puzzle', function () {
  it('puzzle with three letters', function () {
    var puzzle = 'I + BB == ILL';
    var expected = {
      'I': 1,
      'B': 9,
      'L': 0
    };
    expect(solve(puzzle)).toEqual(expected);
  });

  xit('solution must have unique value for each letter', function () {
    var puzzle = 'A == B';
    expect(solve(puzzle)).toBeNull();
  });

  xit('leading zero solution is invalid', function () {
    var puzzle = 'ACA + DD == BD';
    expect(solve(puzzle)).toBeNull();
  });

  xit('puzzle with four letters', function () {
    var puzzle = 'AS + A == MOM';
    var expected =  {
      'A': 9,
      'S': 2,
      'M': 1,
      'O': 0
    };
    expect(solve(puzzle)).toEqual(expected);
  });

  xit('puzzle with six letters', function () {
    var puzzle = 'NO + NO + TOO == LATE';
    var expected =  {
      'N': 7,
      'O': 4,
      'T': 9,
      'L': 1,
      'A': 0,
      'E': 2
    };
    expect(solve(puzzle)).toEqual(expected);
  });

  xit('puzzle with seven letters', function () {
    var puzzle = 'HE + SEES + THE == LIGHT';
    var expected =  {
      'E': 4,
      'G': 2,
      'H': 5,
      'I': 0,
      'L': 1,
      'S': 9,
      'T': 7
    };
    expect(solve(puzzle)).toEqual(expected);
  });

  xit('puzzle with eight letters', function () {
    var puzzle = 'SEND + MORE == MONEY';
    var expected =  {
      'S': 9,
      'E': 5,
      'N': 6,
      'D': 7,
      'M': 1,
      'O': 0,
      'R': 8,
      'Y': 2
    };
    expect(solve(puzzle)).toEqual(expected);
  });

  xit('puzzle with ten letters', function () {
    var puzzle = 'AND + A + STRONG + OFFENSE + AS + A + GOOD == DEFENSE';
    var expected =   {
      'A': 5,
      'D': 3,
      'E': 4,
      'F': 7,
      'G': 8,
      'N': 0,
      'O': 2,
      'R': 1,
      'S': 6,
      'T': 9
    };
    expect(solve(puzzle)).toEqual(expected);
  });
});

Version data entries

141 entries across 141 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.97 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.96 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.95 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.94 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.93 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.92 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.91 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.90 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.89 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.88 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.87 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.86 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.85 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.84 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.83 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.82 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.81 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.80 tracks/javascript/exercises/alphametics/alphametics.spec.js
trackler-2.2.1.79 tracks/javascript/exercises/alphametics/alphametics.spec.js