Skip to content

Commit eb5fa5a

Browse files
committed
Integrate SonarLint suggestions in AoC 2017 solutions
1 parent ec51d85 commit eb5fa5a

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

advent-of-code/2017/day-01/test.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,41 @@ const partTwo = require('./partTwo');
55
describe('Day 1: Inverse Captcha', () => {
66
describe('Part 1', () => {
77
it('should evaluate captcha 1122', () => {
8-
assert.equal(3, partOne([1, 1, 2, 2]));
8+
assert.strictEqual(3, partOne([1, 1, 2, 2]));
99
});
1010

1111
it('should evaluate captcha 1111', () => {
12-
assert.equal(4, partOne([1, 1, 1, 1]));
12+
assert.strictEqual(4, partOne([1, 1, 1, 1]));
1313
});
1414

1515
it('should evaluate captcha 1234', () => {
16-
assert.equal(0, partOne([1, 2, 3, 4]));
16+
assert.strictEqual(0, partOne([1, 2, 3, 4]));
1717
});
1818

1919
it('should evaluate captcha 91212129', () => {
20-
assert.equal(9, partOne([9, 1, 2, 1, 2, 1, 2, 9]));
20+
assert.strictEqual(9, partOne([9, 1, 2, 1, 2, 1, 2, 9]));
2121
});
2222
});
2323

2424
describe('Part 2', () => {
2525
it('should evaluate captcha 1212', () => {
26-
assert.equal(6, partTwo([1, 2, 1, 2]));
26+
assert.strictEqual(6, partTwo([1, 2, 1, 2]));
2727
});
2828

2929
it('should evaluate captcha 1221', () => {
30-
assert.equal(0, partTwo([1, 2, 2, 1]));
30+
assert.strictEqual(0, partTwo([1, 2, 2, 1]));
3131
});
3232

3333
it('should evaluate captcha 123425', () => {
34-
assert.equal(4, partTwo([1, 2, 3, 4, 2, 5]));
34+
assert.strictEqual(4, partTwo([1, 2, 3, 4, 2, 5]));
3535
});
3636

3737
it('should evaluate captcha 123123', () => {
38-
assert.equal(12, partTwo([1, 2, 3, 1, 2, 3]));
38+
assert.strictEqual(12, partTwo([1, 2, 3, 1, 2, 3]));
3939
});
4040

4141
it('should evaluate captcha 12131415', () => {
42-
assert.equal(4, partTwo([1, 2, 1, 3, 1, 4, 1, 5]));
42+
assert.strictEqual(4, partTwo([1, 2, 1, 3, 1, 4, 1, 5]));
4343
});
4444
});
4545
});

advent-of-code/2017/day-02/partTwo.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/* eslint array-callback-return: "off", consistent-return: "off" */
22
const partTwo = (rows) => rows.reduce((checksum, row) => {
3-
for (let i = 0; i < row.length; i++) {
4-
const candidates = row.filter((x) => x < row[i]);
3+
for (const number of row) {
4+
const candidates = row.filter((x) => x < number);
55

6-
for (let j = 0; j < candidates.length; j++) {
7-
if (row[i] % candidates[j] === 0) {
8-
return checksum + row[i] / candidates[j];
6+
for (const candidate of candidates) {
7+
if (number % candidate === 0) {
8+
return checksum + number / candidate;
99
}
1010
}
1111
}

advent-of-code/2017/day-02/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ describe('Day 2: Corruption Checksum', () => {
77
it('should calculate checksum as 18', () => {
88
const SPREADSHEET = [[5, 1, 9, 5], [7, 5, 3], [2, 4, 6, 8]];
99

10-
assert.equal(18, partOne(SPREADSHEET));
10+
assert.strictEqual(18, partOne(SPREADSHEET));
1111
});
1212
});
1313

1414
describe('Part 2', () => {
1515
it('should calculate second checksum as 9', () => {
1616
const SPREADSHEET = [[5, 9, 2, 8], [9, 4, 7, 3], [3, 8, 6, 5]];
1717

18-
assert.equal(9, partTwo(SPREADSHEET));
18+
assert.strictEqual(9, partTwo(SPREADSHEET));
1919
});
2020
});
2121
});

advent-of-code/2017/day-03/test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@ const partTwo = require('./partTwo');
55
describe('Day 3: Spiral Memory', () => {
66
describe('Part 1', () => {
77
it('should calculate steps for square 1', () => {
8-
assert.equal(0, partOne(1));
8+
assert.strictEqual(0, partOne(1));
99
});
1010

1111
it('should calculate steps for square 12', () => {
12-
assert.equal(3, partOne(12));
12+
assert.strictEqual(3, partOne(12));
1313
});
1414

1515
it('should calculate steps for square 23', () => {
16-
assert.equal(2, partOne(23));
16+
assert.strictEqual(2, partOne(23));
1717
});
1818

1919
it('should calculate steps for square 1024', () => {
20-
assert.equal(31, partOne(1024));
20+
assert.strictEqual(31, partOne(1024));
2121
});
2222
});
2323

2424
describe('Part 2', () => {
2525
it('should calculate the first value in the sequence larger than 10', () => {
26-
assert.equal(11, partTwo(10));
26+
assert.strictEqual(11, partTwo(10));
2727
});
2828

2929
it('should calculate the first value in the sequence larger than 59', () => {
30-
assert.equal(122, partTwo(59));
30+
assert.strictEqual(122, partTwo(59));
3131
});
3232
});
3333
});

advent-of-code/2017/day-04/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('Day 4: High-Entropy Passphrases', () => {
1111
['aa', 'bb', 'cc', 'dd', 'aaa']
1212
];
1313

14-
assert.equal(2, partOne(PASSPHRASES));
14+
assert.strictEqual(2, partOne(PASSPHRASES));
1515
});
1616
});
1717

@@ -25,7 +25,7 @@ describe('Day 4: High-Entropy Passphrases', () => {
2525
['oiii', 'ioii', 'iioi', 'iiio']
2626
];
2727

28-
assert.equal(3, partTwo(PASSPHRASES));
28+
assert.strictEqual(3, partTwo(PASSPHRASES));
2929
});
3030
});
3131
});

advent-of-code/2017/day-05/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ describe('Day 5: A Maze of Twisty Trampolines, All Alike', () => {
77

88
describe('Part 1', () => {
99
it('should calculate 5 steps needed', () => {
10-
assert.equal(5, partOne(OFFSETS));
10+
assert.strictEqual(5, partOne(OFFSETS));
1111
});
1212
});
1313

1414
describe('Part 2', () => {
1515
it('should calculate 10 steps needed', () => {
16-
assert.equal(10, partTwo(OFFSETS));
16+
assert.strictEqual(10, partTwo(OFFSETS));
1717
});
1818
});
1919
});

advent-of-code/2017/day-06/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ describe('Day 6: Memory Reallocation', () => {
77

88
describe('Part 1', () => {
99
it('should calculate 5 steps', () => {
10-
assert.equal(partOne(BANKS), 5);
10+
assert.strictEqual(partOne(BANKS), 5);
1111
});
1212
});
1313

1414
describe('Part Two', () => {
1515
it('should calculate loop size 4', () => {
16-
assert.equal(partTwo(BANKS), 4);
16+
assert.strictEqual(partTwo(BANKS), 4);
1717
});
1818
});
1919
});

0 commit comments

Comments
 (0)