Skip to content

Commit 8aa99e7

Browse files
committed
chore: prepare project for adventjs 2023
1 parent df07008 commit 8aa99e7

File tree

24 files changed

+1070
-810
lines changed

24 files changed

+1070
-810
lines changed

.eslintrc.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

.lintstagedrc.cjs

Lines changed: 0 additions & 4 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

2021/challenge-04/challenge-04.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export function createXmasTree(height: number) {
55
.repeat(2 * i + 1)
66
.padStart(i + height, '_')
77
.padEnd(height * 2 - 1, '_')
8-
.concat('\n')
8+
.concat('\n'),
99
)
1010
.join('')
1111

2021/challenge-06/challenge-06.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function sumPairs(numbers: number[], result: number) {
1414

1515
return [acc, pairs]
1616
},
17-
[numbers[0], [numbers[0]]]
17+
[numbers[0], [numbers[0]]],
1818
)
1919

2020
return sum(pairs) === result ? pairs : null

2021/challenge-07/challenge-07.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export function contains(
22
store: string | Record<string, any>,
3-
product: string
3+
product: string,
44
): boolean {
55
if (typeof store === 'object') {
66
return Object.values(store).some(value => contains(value, product))

2021/challenge-09/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ groupBy(['one', 'two', 'three'], 'length') // { 3: ['one', 'two'], 5: ['three']
1414
groupBy([{ age: 23 }, { age: 24 }], 'age') // { 23: [{age: 23}], 24: [{age: 24}] }
1515

1616
groupBy([1397639141184, 1363223700000], timestamp =>
17-
new Date(timestamp).getFullYear()
17+
new Date(timestamp).getFullYear(),
1818
)
1919
// { 2013: [1363223700000], 2014: [1397639141184] }
2020

@@ -24,7 +24,7 @@ groupBy(
2424
{ title: 'Aprendiendo Git', rating: 10 },
2525
{ title: 'Clean Code', rating: 9 },
2626
],
27-
'rating'
27+
'rating',
2828
)
2929
// { 8: [{ title: 'JavaScript: The Good Parts', rating: 8 }],
3030
// 9: [{ title: 'Clean Code', rating: 9 }],

2021/challenge-09/challenge-09.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export function groupBy<T>(
22
collection: T[],
3-
it: keyof T | ((value: T) => string | number)
3+
it: keyof T | ((value: T) => string | number),
44
): Record<string | number, T[]> {
55
const group: Record<string | number, T[]> = {}
66
const isItFunction = typeof it === 'function'

2021/challenge-10/challenge-10.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function getCoins(change: number) {
1212

1313
return acc
1414
},
15-
[0, 0, 0, 0, 0, 0]
15+
[0, 0, 0, 0, 0, 0],
1616
)
1717
.reverse()
1818
}

2021/challenge-17/challenge-17.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export function countPackages(carriers: Carrier[], carrierID: string): number {
33

44
return carrier[2].reduce(
55
(acc, carrier) => (acc += countPackages(carriers, carrier)),
6-
carrier[1]
6+
carrier[1],
77
)
88
}
99

2022/challenge-05/challenge-05.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
export function getMaxGifts(
33
giftsCities: number[],
44
maxGifts: number,
5-
maxCities: number
5+
maxCities: number,
66
) {
77
return giftsCities
88
.sort((a, b) => b - a)

2022/challenge-07/challenge-07.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// score: 400
22
export function getGiftsToRefill(a1: string[], a2: string[], a3: string[]) {
33
return [...new Set(a1.concat(a2, a3))].filter(
4-
g => (a1.includes(g) as any) + a2.includes(g) + a3.includes(g) === 1
4+
g => (a1.includes(g) as any) + a2.includes(g) + a3.includes(g) === 1,
55
)
66
}

2022/challenge-11/challenge-11.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export function getCompleted(part: string, total: string) {
1111

1212
while (b) {
1313
const aux = b
14-
;(b = gcd % b), (gcd = aux)
14+
b = gcd % b
15+
gcd = aux
1516
}
1617

1718
return `${partSeconds / gcd}/${totalSeconds / gcd}`

2022/challenge-13/challenge-13.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// score: 360
22
export function getFilesToBackup(
33
lastBackup: number,
4-
changes: Array<[number, number]>
4+
changes: Array<[number, number]>,
55
) {
66
const ids = changes.filter(([, time]) => time > lastBackup).map(([id]) => id)
77
const uniqueIds = [...new Set(ids)]

2022/challenge-15/challenge-15.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ export function decorateTree(base: string) {
2525

2626
return [top.join(' '), ...tree]
2727
},
28-
[base]
28+
[base],
2929
)
3030
}

2022/challenge-16/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ Santa Claus is starting to receive a lot of letters but they have some formattin
1414

1515
```js
1616
fixLetter(
17-
` hello, how are you?? do you know if santa claus exists? i really hope he does! bye `
17+
` hello, how are you?? do you know if santa claus exists? i really hope he does! bye `,
1818
)
1919
// Hello, how are you? Do you know if Santa Claus exists? I really hope he does! Bye.
2020

2121
fixLetter(
22-
" Hi Santa claus. I'm a girl from Barcelona , Spain . please, send me a bike. Is it possible?"
22+
" Hi Santa claus. I'm a girl from Barcelona , Spain . please, send me a bike. Is it possible?",
2323
)
2424
// Hi Santa Claus. I'm a girl from Barcelona, Spain. Please, send me a bike. Is it possible?
2525
```

2022/challenge-20/challenge-20.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
export function howManyReindeers(
22
reindeerTypes: Reindeer[],
3-
gifts: Gift[]
3+
gifts: Gift[],
44
): Result[] {
55
reindeerTypes.sort((a, b) => b.weightCapacity - a.weightCapacity)
66

77
return gifts.map(({ country, weight }) => {
88
const remainingRnds = reindeerTypes.filter(x => x.weightCapacity < weight)
99
let total = remainingRnds.reduce(
1010
(acc, curr) => (acc += curr.weightCapacity),
11-
0
11+
0,
1212
)
1313

1414
const reindeers = remainingRnds.map(({ type, weightCapacity }) => {

2022/challenge-21/challenge-21.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ export function printTable(gifts: Gift[]) {
22
const giftWidth = Math.max(...gifts.map(gift => gift.name.length), 4)
33
const quantityWidth = Math.max(
44
...gifts.map(gift => `${gift.quantity}`.length),
5-
8
5+
8,
66
)
77

88
const tableWidth = giftWidth + quantityWidth + 7
99

1010
const top = '+'.repeat(tableWidth)
1111
const bottom = '*'.repeat(tableWidth)
1212
const head = `Gift${' '.repeat(giftWidth - 4)} | Quantity${' '.repeat(
13-
quantityWidth - 8
13+
quantityWidth - 8,
1414
)}`
1515
const border = `${'-'.repeat(giftWidth)} | ${'-'.repeat(quantityWidth)}`
1616
const body = gifts
1717
.map(
1818
gift =>
1919
`| ${gift.name}${' '.repeat(giftWidth - gift.name.length)} | ${
2020
gift.quantity
21-
}${' '.repeat(quantityWidth - `${gift.quantity}`.length)} |`
21+
}${' '.repeat(quantityWidth - `${gift.quantity}`.length)} |`,
2222
)
2323
.join('\n')
2424

2022/challenge-23/challenge-23.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function executeCommands(commands: string[]) {
2020
const [commandName, args] = command.split(' ')
2121
const values = args.split(',').map(v => +v.replace(/V/g, '')) as [
2222
number,
23-
number
23+
number,
2424
]
2525

2626
if (commandName === 'JMP' && registers[0] !== 0) i = values[0] - 1

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2021 Borja Paz Rodríguez borjapazr@gmail.com
3+
Copyright (c) 2023 Will
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

package.json

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,63 @@
11
{
22
"name": "adventjs-challenges",
33
"private": true,
4-
"version": "0.0.0",
4+
"version": "0.0.1",
55
"type": "module",
66
"scripts": {
77
"prepare": "husky install",
88
"format": "prettier -wu .",
99
"format:check": "prettier -cu .",
10-
"lint": "eslint --fix .",
11-
"lint:check": "eslint .",
10+
"lint": "eslint --fix ./**/*.{js,jsx,ts,tsx}",
11+
"lint:check": "eslint ./**/*.{js,jsx,ts,tsx}",
1212
"test": "vitest run",
1313
"test:cov": "vitest run --coverage",
1414
"test:watch": "vitest --watch",
1515
"typecheck": "tsc --noEmit",
1616
"check": "npm run format:check && npm run lint:check && npm run typecheck"
1717
},
1818
"devDependencies": {
19-
"@types/kind-of": "6.0.0",
20-
"@types/node": "18.14.6",
21-
"@typescript-eslint/eslint-plugin": "5.54.1",
22-
"@typescript-eslint/parser": "5.54.1",
23-
"@vitest/coverage-c8": "0.29.2",
24-
"eslint": "8.35.0",
25-
"eslint-config-prettier": "8.7.0",
26-
"eslint-config-standard-with-typescript": "34.0.0",
27-
"eslint-plugin-import": "2.27.5",
28-
"eslint-plugin-n": "15.6.1",
29-
"eslint-plugin-prettier": "4.2.1",
19+
"@types/kind-of": "6.0.3",
20+
"@types/node": "20.10.0",
21+
"@typescript-eslint/eslint-plugin": "6.12.0",
22+
"@typescript-eslint/parser": "6.12.0",
23+
"@vitest/coverage-v8": "0.34.6",
24+
"eslint": "8.54.0",
25+
"eslint-config-prettier": "9.0.0",
26+
"eslint-config-standard-with-typescript": "40.0.0",
27+
"eslint-plugin-import": "2.29.0",
28+
"eslint-plugin-n": "16.3.1",
29+
"eslint-plugin-prettier": "5.0.1",
3030
"eslint-plugin-promise": "6.1.1",
3131
"husky": "8.0.3",
3232
"kind-of": "6.0.3",
33-
"lint-staged": "13.1.2",
34-
"prettier": "2.8.4",
35-
"typescript": "4.9.5",
36-
"vitest": "0.29.2"
33+
"lint-staged": "15.1.0",
34+
"prettier": "3.1.0",
35+
"typescript": "5.2.2",
36+
"vitest": "0.34.6"
37+
},
38+
"eslintConfig": {
39+
"extends": [
40+
"standard-with-typescript",
41+
"plugin:prettier/recommended"
42+
],
43+
"parserOptions": {
44+
"project": "tsconfig.json"
45+
},
46+
"rules": {
47+
"@typescript-eslint/explicit-function-return-type": "off",
48+
"@typescript-eslint/prefer-nullish-coalescing": "off",
49+
"@typescript-eslint/prefer-optional-chain": "off",
50+
"@typescript-eslint/strict-boolean-expressions": "off"
51+
}
52+
},
53+
"prettier": {
54+
"printWidth": 80,
55+
"singleQuote": true,
56+
"semi": false,
57+
"arrowParens": "avoid"
58+
},
59+
"lint-staged": {
60+
"*.{js,ts}": "pnpm eslint --fix",
61+
"*.{json,js,ts,md}": "pnpm prettier -w"
3762
}
3863
}

0 commit comments

Comments
 (0)