Skip to content

Commit 7010138

Browse files
chore: prettier
1 parent 010f543 commit 7010138

File tree

5 files changed

+42
-44
lines changed

5 files changed

+42
-44
lines changed

.prettierrc

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"proseWrap": "preserve",
32
"semi": false,
43
"singleQuote": true,
54
"trailingComma": "none"

2023/day6/src/part1.ts

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
1-
import { loadInput } from '../../../helpers/file';
1+
import { loadInput } from '../../../helpers/file'
22

33
function main() {
4-
const file = loadInput(__dirname);
4+
const file = loadInput(__dirname)
55

6-
const lines = file.trim().split('\n');
6+
const lines = file.trim().split('\n')
77

88
const times = lines[0]
99
.split(/\s+/)
1010
.slice(1)
11-
.map((i) => +i);
11+
.map((i) => +i)
1212

1313
const distance = lines[1]
1414
.split(/\s+/)
1515
.slice(1)
16-
.map((i) => +i);
16+
.map((i) => +i)
1717

1818
return times
1919
.map((time, idx) => {
20-
let sum: number[] = [];
20+
let sum: number[] = []
2121
for (let i = 0; i <= time; i++) {
2222
let x = time,
23-
y = x - i;
23+
y = x - i
2424

2525
if (y * i > distance[idx]) {
26-
sum.push(i);
26+
sum.push(i)
2727
}
2828
}
2929

30-
return sum;
30+
return sum
3131
})
32-
.reduce((a, c) => a * c.length, 1);
32+
.reduce((a, c) => a * c.length, 1)
3333
}
3434

35-
main();
36-
35+
main()

helpers/file.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import fs from 'fs';
2-
import path from 'path';
1+
import fs from 'fs'
2+
import path from 'path'
33

44
function loadInput(dir) {
5-
const filePath = path.join(dir, '/bin/input.txt');
6-
return fs.readFileSync(filePath).toString();
5+
const filePath = path.join(dir, '/bin/input.txt')
6+
return fs.readFileSync(filePath).toString()
77
}
88

9-
export { loadInput };
9+
export { loadInput }
+14-14
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { promises } from 'fs';
2-
import { resolve } from 'path';
3-
import { part1, part2 } from '.';
1+
import { promises } from 'fs'
2+
import { resolve } from 'path'
3+
import { part1, part2 } from '.'
44

55
let data = promises.readFile(
66
resolve(process.cwd(), 'data', '{{YEAR}}-{{DAY}}.txt'),
77
'utf8'
8-
);
8+
)
99

1010
describe('Part 1', () => {
1111
it.each([
@@ -16,13 +16,13 @@ describe('Part 1', () => {
1616
'TODO'
1717
]
1818
])('should produce the correct value for example %#', (input, expected) => {
19-
expect(part1(input)).toBe(expected);
20-
});
19+
expect(part1(input)).toBe(expected)
20+
})
2121

2222
it.skip('should produce the correct value for the input data', async () => {
23-
expect(part1(await data)).toMatchInlineSnapshot();
24-
});
25-
});
23+
expect(part1(await data)).toMatchInlineSnapshot()
24+
})
25+
})
2626

2727
describe.skip('Part 2', () => {
2828
it.each([
@@ -33,10 +33,10 @@ describe.skip('Part 2', () => {
3333
'TODO'
3434
]
3535
])('should produce the correct value for example %#', (input, expected) => {
36-
expect(part2(input)).toBe(expected);
37-
});
36+
expect(part2(input)).toBe(expected)
37+
})
3838

3939
it.skip('should produce the correct value for the input data', async () => {
40-
expect(part2(await data)).toMatchInlineSnapshot();
41-
});
42-
});
40+
expect(part2(await data)).toMatchInlineSnapshot()
41+
})
42+
})

templates/day/typescript/index.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
import { resolve } from 'node:path';
2-
import { readFile } from 'node:fs/promises';
1+
import { resolve } from 'node:path'
2+
import { readFile } from 'node:fs/promises'
33

44
async function main() {
55
let data = await readFile(
66
resolve('../../../../', 'data', '{{YEAR}}-{{DAY}}.txt'),
77
'utf8'
8-
);
8+
)
99

1010
// Part 1
1111
{
12-
console.time('Part 1');
13-
let result = part1(data);
14-
console.log('Result:', result);
15-
console.timeEnd('Part 1');
12+
console.time('Part 1')
13+
let result = part1(data)
14+
console.log('Result:', result)
15+
console.timeEnd('Part 1')
1616
}
1717

1818
// Part 2
1919
{
20-
console.time('Part 2');
21-
let result = part2(data);
22-
console.log('Result:', result);
23-
console.timeEnd('Part 2');
20+
console.time('Part 2')
21+
let result = part2(data)
22+
console.log('Result:', result)
23+
console.timeEnd('Part 2')
2424
}
2525
}
2626

27-
main();
27+
main()
2828

2929
export function part1(data: string) {}
3030

0 commit comments

Comments
 (0)