Skip to content

Commit c68b8de

Browse files
Merge pull request #14 from amclin/dependabot/npm_and_yarn/standard-13.1.0
chore(deps-dev): bump standard from 12.0.1 to 13.1.0
2 parents a955e3d + d806d2c commit c68b8de

40 files changed

+658
-452
lines changed

2018/day-01/part-1/chronalCalibrator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const parseData = require('../../inputParser').parseData
55
* @param {String} input list of values
66
*/
77
const chronalCalibrator = (input) => {
8-
let adjustments = parseData(input)
8+
const adjustments = parseData(input)
99
return adjustments.reduce(
1010
(total, current) => total + current
1111
)

2018/day-01/part-1/chronalCalibrator.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ describe('--- Day 1: Chronal Calibration ---', () => {
77
it('should add a list frequency values', () => {
88
const sequence = '+1, +1, +1'
99
const expected = 3
10-
let actual = chronalCalibrator(sequence)
10+
const actual = chronalCalibrator(sequence)
1111
expect(actual).to.equal(expected)
1212
})
1313

1414
it('should subtract a list frequency values', () => {
1515
const sequence = '-1, -2, -3'
1616
const expected = -6
17-
let actual = chronalCalibrator(sequence)
17+
const actual = chronalCalibrator(sequence)
1818
expect(actual).to.equal(expected)
1919
})
2020

2121
it('should add a add and subtract a mixed list of frequency values', () => {
2222
const sequence = '+1, +1, -2'
2323
const expected = 0
24-
let actual = chronalCalibrator(sequence)
24+
const actual = chronalCalibrator(sequence)
2525
expect(actual).to.equal(expected)
2626
})
2727

@@ -31,7 +31,7 @@ describe('--- Day 1: Chronal Calibration ---', () => {
3131
+1
3232
-2`
3333
const expected = 0
34-
let actual = chronalCalibrator(sequence)
34+
const actual = chronalCalibrator(sequence)
3535
expect(actual).to.equal(expected)
3636
})
3737
})

2018/day-01/part-1/solution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ const filePath = path.join(__dirname, '../input.txt')
55

66
fs.readFile(filePath, { encoding: 'utf8' }, (err, data) => {
77
if (err) throw err
8-
let answer = chronalCalibrator(data)
8+
const answer = chronalCalibrator(data)
99
console.log(`Answer: ${answer}`)
1010
})

2018/day-01/part-2/chronalCalibrator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const parseData = require('../../inputParser').parseData
55
* @param {String} input list of values
66
*/
77
function getFrequency (input) {
8-
let adjustments = parseData(input)
8+
const adjustments = parseData(input)
99
return adjustments.reduce(
1010
(total, current) => total + current
1111
)
@@ -19,7 +19,7 @@ function getFirstMatch (input) {
1919
const sequence = parseData(input)
2020
let freq = 0
2121
let idx = 0
22-
let log = [freq]
22+
const log = [freq]
2323
let matched = null
2424
do {
2525
// Adjust Frequence

2018/day-01/part-2/chronalCalibrator.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ describe('--- Day 1: Chronal Calibration ---', () => {
77
it('finds the first frequency that is reached twice in test set 1', () => {
88
const sequence = '+1, -1'
99
const expected = 0
10-
let actual = chronalCalibrator.getFirstMatch(sequence)
10+
const actual = chronalCalibrator.getFirstMatch(sequence)
1111
expect(actual).to.equal(expected)
1212
})
1313

1414
it('finds the first frequency that is reached twice in test set 2', () => {
1515
const sequence = '+3, +3, +4, -2, -4'
1616
const expected = 10
17-
let actual = chronalCalibrator.getFirstMatch(sequence)
17+
const actual = chronalCalibrator.getFirstMatch(sequence)
1818
expect(actual).to.equal(expected)
1919
})
2020

2121
it('finds the first frequency that is reached twice in test set 3', () => {
2222
const sequence = '-6, +3, +8, +5, -6'
2323
const expected = 5
24-
let actual = chronalCalibrator.getFirstMatch(sequence)
24+
const actual = chronalCalibrator.getFirstMatch(sequence)
2525
expect(actual).to.equal(expected)
2626
})
2727

2828
it('finds the first frequency that is reached twice in test set 4', () => {
2929
const sequence = '+7, +7, -2, -7, -4'
3030
const expected = 14
31-
let actual = chronalCalibrator.getFirstMatch(sequence)
31+
const actual = chronalCalibrator.getFirstMatch(sequence)
3232
expect(actual).to.equal(expected)
3333
})
3434
})

2018/day-01/part-2/solution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ const filePath = path.join(__dirname, '../input.txt')
55

66
fs.readFile(filePath, { encoding: 'utf8' }, (err, data) => {
77
if (err) throw err
8-
let answer = chronalCalibrator.getFirstMatch(data)
8+
const answer = chronalCalibrator.getFirstMatch(data)
99
console.log(`Answer: ${answer}`)
1010
})

2018/day-02/boxes.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const unique = require('../helpers').unique
44
const hasNRepeatedChars = (haystack, n) => {
55
let chars = unique(haystack.split(''))
66
chars = chars.filter((char) => {
7-
let needle = new RegExp(char, 'g')
8-
let count = (haystack.match(needle) || []).length // find number of results in the ID
7+
const needle = new RegExp(char, 'g')
8+
const count = (haystack.match(needle) || []).length // find number of results in the ID
99
return (count === n)
1010
})
1111
return (chars.length > 0)
@@ -30,7 +30,7 @@ function getChecksum (input) {
3030
* @returns {number}
3131
*/
3232
const scoreIDs = (str1, str2) => {
33-
let common = getCommonLetters(str1, str2)
33+
const common = getCommonLetters(str1, str2)
3434
return str1.length - common.length
3535
}
3636

@@ -56,14 +56,14 @@ const getCommonLetters = (str1, str2) => {
5656
* @returns {Array} list of similar IDs
5757
*/
5858
const findSimilarIDs = (ids, threshold) => {
59-
let results = []
59+
const results = []
6060
threshold = threshold || 1
6161

6262
let searchIdx = 0
6363
do {
64-
let needle = ids[searchIdx]
64+
const needle = ids[searchIdx]
6565
// Find matches that differ by only one letter
66-
let matches = ids.filter((id, idx) => {
66+
const matches = ids.filter((id, idx) => {
6767
// Don't repeat comparisons and don't compare to self
6868
if (searchIdx <= idx) {
6969
return false

2018/day-02/solution.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ const filePath = path.join(__dirname, 'input.txt')
55

66
fs.readFile(filePath, { encoding: 'utf8' }, (err, data) => {
77
if (err) throw err
8-
let answer = boxes.getChecksum(data)
8+
const answer = boxes.getChecksum(data)
99
console.log(`-- Part 1 --`)
1010
console.log(`Answer: ${answer}`)
1111

12-
let ids = boxes.getListFromData(data)
13-
let similar = boxes.findSimilarIDs(ids)
14-
let answer2 = boxes.getCommonLetters(similar[0], similar[1])
12+
const ids = boxes.getListFromData(data)
13+
const similar = boxes.findSimilarIDs(ids)
14+
const answer2 = boxes.getCommonLetters(similar[0], similar[1])
1515
console.log(`-- Part 2 --`)
1616
console.log(`Answer: ${answer2}`)
1717
})

2018/day-03/claims.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const makeClaim = (claim) => {
100100
* @returns {Object} Claim object with named properties
101101
*/
102102
const parseClaim = (str) => {
103-
let claim = {}
103+
const claim = {}
104104
let vals = str.split(' @ ')
105105
claim.id = vals[0].replace(/#/g, '')
106106
vals = vals[1].split(',')

2018/day-03/claims.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ describe('--- Day 3: No Matter How You Slice It ---', () => {
4646
describe('makeClaim(claim)', () => {
4747
it('marks the points on the cloth with the claim ID', () => {
4848
const claim = parseClaim(claims[0])
49-
let result = makeClaim(claim)
49+
const result = makeClaim(claim)
5050
expect(result[1][1]).to.equal(undefined)
5151
expect(result[3][2]).to.deep.equal([123])
5252
expect(result[7][5]).to.deep.equal([123])
5353
})
5454

5555
it('marks the points that are overlapped', () => {
56-
let testClaims = claims.map(parseClaim)
56+
const testClaims = claims.map(parseClaim)
5757
let result = _cloth
5858
for (let x = 1; x < claims.length; x++) {
5959
result = makeClaim(testClaims[x])
@@ -91,7 +91,7 @@ describe('--- Day 3: No Matter How You Slice It ---', () => {
9191

9292
describe('countConflicts()', () => {
9393
it('counts the number of points with conflicting claims', () => {
94-
let testClaims = claims.map(parseClaim)
94+
const testClaims = claims.map(parseClaim)
9595
for (let x = 1; x < claims.length; x++) {
9696
makeClaim(testClaims[x])
9797
}
@@ -105,7 +105,7 @@ describe('--- Day 3: No Matter How You Slice It ---', () => {
105105
describe('Part 2', () => {
106106
describe('findNonOverlappingClaims()', () => {
107107
it('locates the first claim that doesn\'t have overlapping claims', () => {
108-
let testClaims = claims.map(parseClaim)
108+
const testClaims = claims.map(parseClaim)
109109
for (let x = 1; x < claims.length; x++) {
110110
makeClaim(testClaims[x])
111111
}

0 commit comments

Comments
 (0)