Skip to content

Commit

Permalink
chore: prepare project for adventjs 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
iswilljr committed Dec 1, 2023
1 parent df07008 commit 8aa99e7
Show file tree
Hide file tree
Showing 24 changed files with 1,070 additions and 810 deletions.
22 changes: 0 additions & 22 deletions .eslintrc.json

This file was deleted.

4 changes: 0 additions & 4 deletions .lintstagedrc.cjs

This file was deleted.

6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

2 changes: 1 addition & 1 deletion 2021/challenge-04/challenge-04.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function createXmasTree(height: number) {
.repeat(2 * i + 1)
.padStart(i + height, '_')
.padEnd(height * 2 - 1, '_')
.concat('\n')
.concat('\n'),
)
.join('')

Expand Down
2 changes: 1 addition & 1 deletion 2021/challenge-06/challenge-06.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function sumPairs(numbers: number[], result: number) {

return [acc, pairs]
},
[numbers[0], [numbers[0]]]
[numbers[0], [numbers[0]]],
)

return sum(pairs) === result ? pairs : null
Expand Down
2 changes: 1 addition & 1 deletion 2021/challenge-07/challenge-07.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function contains(
store: string | Record<string, any>,
product: string
product: string,
): boolean {
if (typeof store === 'object') {
return Object.values(store).some(value => contains(value, product))
Expand Down
4 changes: 2 additions & 2 deletions 2021/challenge-09/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ groupBy(['one', 'two', 'three'], 'length') // { 3: ['one', 'two'], 5: ['three']
groupBy([{ age: 23 }, { age: 24 }], 'age') // { 23: [{age: 23}], 24: [{age: 24}] }

groupBy([1397639141184, 1363223700000], timestamp =>
new Date(timestamp).getFullYear()
new Date(timestamp).getFullYear(),
)
// { 2013: [1363223700000], 2014: [1397639141184] }

Expand All @@ -24,7 +24,7 @@ groupBy(
{ title: 'Aprendiendo Git', rating: 10 },
{ title: 'Clean Code', rating: 9 },
],
'rating'
'rating',
)
// { 8: [{ title: 'JavaScript: The Good Parts', rating: 8 }],
// 9: [{ title: 'Clean Code', rating: 9 }],
Expand Down
2 changes: 1 addition & 1 deletion 2021/challenge-09/challenge-09.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function groupBy<T>(
collection: T[],
it: keyof T | ((value: T) => string | number)
it: keyof T | ((value: T) => string | number),
): Record<string | number, T[]> {
const group: Record<string | number, T[]> = {}
const isItFunction = typeof it === 'function'
Expand Down
2 changes: 1 addition & 1 deletion 2021/challenge-10/challenge-10.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function getCoins(change: number) {

return acc
},
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0],
)
.reverse()
}
2 changes: 1 addition & 1 deletion 2021/challenge-17/challenge-17.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export function countPackages(carriers: Carrier[], carrierID: string): number {

return carrier[2].reduce(
(acc, carrier) => (acc += countPackages(carriers, carrier)),
carrier[1]
carrier[1],
)
}

Expand Down
2 changes: 1 addition & 1 deletion 2022/challenge-05/challenge-05.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export function getMaxGifts(
giftsCities: number[],
maxGifts: number,
maxCities: number
maxCities: number,
) {
return giftsCities
.sort((a, b) => b - a)
Expand Down
2 changes: 1 addition & 1 deletion 2022/challenge-07/challenge-07.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// score: 400
export function getGiftsToRefill(a1: string[], a2: string[], a3: string[]) {
return [...new Set(a1.concat(a2, a3))].filter(
g => (a1.includes(g) as any) + a2.includes(g) + a3.includes(g) === 1
g => (a1.includes(g) as any) + a2.includes(g) + a3.includes(g) === 1,
)
}
3 changes: 2 additions & 1 deletion 2022/challenge-11/challenge-11.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export function getCompleted(part: string, total: string) {

while (b) {
const aux = b
;(b = gcd % b), (gcd = aux)
b = gcd % b
gcd = aux
}

return `${partSeconds / gcd}/${totalSeconds / gcd}`
Expand Down
2 changes: 1 addition & 1 deletion 2022/challenge-13/challenge-13.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// score: 360
export function getFilesToBackup(
lastBackup: number,
changes: Array<[number, number]>
changes: Array<[number, number]>,
) {
const ids = changes.filter(([, time]) => time > lastBackup).map(([id]) => id)
const uniqueIds = [...new Set(ids)]
Expand Down
2 changes: 1 addition & 1 deletion 2022/challenge-15/challenge-15.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export function decorateTree(base: string) {

return [top.join(' '), ...tree]
},
[base]
[base],
)
}
4 changes: 2 additions & 2 deletions 2022/challenge-16/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Santa Claus is starting to receive a lot of letters but they have some formattin

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

fixLetter(
" Hi Santa claus. I'm a girl from Barcelona , Spain . please, send me a bike. Is it possible?"
" Hi Santa claus. I'm a girl from Barcelona , Spain . please, send me a bike. Is it possible?",
)
// Hi Santa Claus. I'm a girl from Barcelona, Spain. Please, send me a bike. Is it possible?
```
Expand Down
4 changes: 2 additions & 2 deletions 2022/challenge-20/challenge-20.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export function howManyReindeers(
reindeerTypes: Reindeer[],
gifts: Gift[]
gifts: Gift[],
): Result[] {
reindeerTypes.sort((a, b) => b.weightCapacity - a.weightCapacity)

return gifts.map(({ country, weight }) => {
const remainingRnds = reindeerTypes.filter(x => x.weightCapacity < weight)
let total = remainingRnds.reduce(
(acc, curr) => (acc += curr.weightCapacity),
0
0,
)

const reindeers = remainingRnds.map(({ type, weightCapacity }) => {
Expand Down
6 changes: 3 additions & 3 deletions 2022/challenge-21/challenge-21.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ export function printTable(gifts: Gift[]) {
const giftWidth = Math.max(...gifts.map(gift => gift.name.length), 4)
const quantityWidth = Math.max(
...gifts.map(gift => `${gift.quantity}`.length),
8
8,
)

const tableWidth = giftWidth + quantityWidth + 7

const top = '+'.repeat(tableWidth)
const bottom = '*'.repeat(tableWidth)
const head = `Gift${' '.repeat(giftWidth - 4)} | Quantity${' '.repeat(
quantityWidth - 8
quantityWidth - 8,
)}`
const border = `${'-'.repeat(giftWidth)} | ${'-'.repeat(quantityWidth)}`
const body = gifts
.map(
gift =>
`| ${gift.name}${' '.repeat(giftWidth - gift.name.length)} | ${
gift.quantity
}${' '.repeat(quantityWidth - `${gift.quantity}`.length)} |`
}${' '.repeat(quantityWidth - `${gift.quantity}`.length)} |`,
)
.join('\n')

Expand Down
2 changes: 1 addition & 1 deletion 2022/challenge-23/challenge-23.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function executeCommands(commands: string[]) {
const [commandName, args] = command.split(' ')
const values = args.split(',').map(v => +v.replace(/V/g, '')) as [
number,
number
number,
]

if (commandName === 'JMP' && registers[0] !== 0) i = values[0] - 1
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

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

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
61 changes: 43 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,63 @@
{
"name": "adventjs-challenges",
"private": true,
"version": "0.0.0",
"version": "0.0.1",
"type": "module",
"scripts": {
"prepare": "husky install",
"format": "prettier -wu .",
"format:check": "prettier -cu .",
"lint": "eslint --fix .",
"lint:check": "eslint .",
"lint": "eslint --fix ./**/*.{js,jsx,ts,tsx}",
"lint:check": "eslint ./**/*.{js,jsx,ts,tsx}",
"test": "vitest run",
"test:cov": "vitest run --coverage",
"test:watch": "vitest --watch",
"typecheck": "tsc --noEmit",
"check": "npm run format:check && npm run lint:check && npm run typecheck"
},
"devDependencies": {
"@types/kind-of": "6.0.0",
"@types/node": "18.14.6",
"@typescript-eslint/eslint-plugin": "5.54.1",
"@typescript-eslint/parser": "5.54.1",
"@vitest/coverage-c8": "0.29.2",
"eslint": "8.35.0",
"eslint-config-prettier": "8.7.0",
"eslint-config-standard-with-typescript": "34.0.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-n": "15.6.1",
"eslint-plugin-prettier": "4.2.1",
"@types/kind-of": "6.0.3",
"@types/node": "20.10.0",
"@typescript-eslint/eslint-plugin": "6.12.0",
"@typescript-eslint/parser": "6.12.0",
"@vitest/coverage-v8": "0.34.6",
"eslint": "8.54.0",
"eslint-config-prettier": "9.0.0",
"eslint-config-standard-with-typescript": "40.0.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-n": "16.3.1",
"eslint-plugin-prettier": "5.0.1",
"eslint-plugin-promise": "6.1.1",
"husky": "8.0.3",
"kind-of": "6.0.3",
"lint-staged": "13.1.2",
"prettier": "2.8.4",
"typescript": "4.9.5",
"vitest": "0.29.2"
"lint-staged": "15.1.0",
"prettier": "3.1.0",
"typescript": "5.2.2",
"vitest": "0.34.6"
},
"eslintConfig": {
"extends": [
"standard-with-typescript",
"plugin:prettier/recommended"
],
"parserOptions": {
"project": "tsconfig.json"
},
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/prefer-optional-chain": "off",
"@typescript-eslint/strict-boolean-expressions": "off"
}
},
"prettier": {
"printWidth": 80,
"singleQuote": true,
"semi": false,
"arrowParens": "avoid"
},
"lint-staged": {
"*.{js,ts}": "pnpm eslint --fix",
"*.{json,js,ts,md}": "pnpm prettier -w"
}
}
Loading

0 comments on commit 8aa99e7

Please sign in to comment.