Skip to content

Commit 010f543

Browse files
fix: consistent language templates
1 parent 8854b0c commit 010f543

File tree

5 files changed

+48
-61
lines changed

5 files changed

+48
-61
lines changed

templates/day/rust/src/main.rs

+17-9
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,23 @@ use std::time::Instant;
33
const INPUT: &str = include_str!("../../../../../data/{{YEAR}}-{{DAY}}.txt");
44

55
fn main() {
6-
let now = Instant::now();
7-
let part_1_result = part_1(INPUT);
8-
let duration = now.elapsed();
9-
println!("Part 1: {:<20}(took: {:>12?})", part_1_result, duration);
10-
11-
let now = Instant::now();
12-
let part_2_result = part_2(INPUT);
13-
let duration = now.elapsed();
14-
println!("Part 2: {:<20}(took: {:>12?})", part_2_result, duration);
6+
// Part 1
7+
{
8+
let now = Instant::now();
9+
let result = part_1(INPUT);
10+
let duration = now.elapsed();
11+
println!("Result: {}", result);
12+
println!("Part 1 {:?}", duration);
13+
}
14+
15+
// Part 2
16+
{
17+
let now = Instant::now();
18+
let result = part_2(INPUT);
19+
let duration = now.elapsed();
20+
println!("Result: {}", result);
21+
println!("Part 2 {:?}", duration);
22+
}
1523
}
1624

1725
pub fn part_1(data: &str) -> i32 {
+14-16
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { promises } from 'fs'
2-
import { resolve } from 'path'
3-
4-
import part1 from './part-1'
5-
import part2 from './part-2'
1+
import { promises } from 'fs';
2+
import { resolve } from 'path';
3+
import { part1, part2 } from '.';
64

75
let data = promises.readFile(
86
resolve(process.cwd(), 'data', '{{YEAR}}-{{DAY}}.txt'),
97
'utf8'
10-
)
8+
);
119

1210
describe('Part 1', () => {
1311
it.each([
@@ -18,13 +16,13 @@ describe('Part 1', () => {
1816
'TODO'
1917
]
2018
])('should produce the correct value for example %#', (input, expected) => {
21-
expect(part1(input)).toBe(expected)
22-
})
19+
expect(part1(input)).toBe(expected);
20+
});
2321

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

2927
describe.skip('Part 2', () => {
3028
it.each([
@@ -35,10 +33,10 @@ describe.skip('Part 2', () => {
3533
'TODO'
3634
]
3735
])('should produce the correct value for example %#', (input, expected) => {
38-
expect(part2(input)).toBe(expected)
39-
})
36+
expect(part2(input)).toBe(expected);
37+
});
4038

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

templates/day/typescript/index.ts

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
1-
import { resolve } from 'node:path'
2-
import { readFile } from 'node:fs/promises'
3-
4-
import part1 from './part-1'
5-
import part2 from './part-2'
1+
import { resolve } from 'node:path';
2+
import { readFile } from 'node:fs/promises';
63

74
async function main() {
85
let data = await readFile(
9-
resolve('./', 'data', '{{YEAR}}-{{DAY}}.txt'),
6+
resolve('../../../../', 'data', '{{YEAR}}-{{DAY}}.txt'),
107
'utf8'
11-
)
8+
);
129

1310
// Part 1
1411
{
15-
console.time('Part 1')
16-
let result = part1(data)
17-
console.log('Result:', result)
18-
console.timeEnd('Part 1')
12+
console.time('Part 1');
13+
let result = part1(data);
14+
console.log('Result:', result);
15+
console.timeEnd('Part 1');
1916
}
2017

2118
// Part 2
2219
{
23-
console.time('Part 2')
24-
let result = part2(data)
25-
console.log('Result:', result)
26-
console.timeEnd('Part 2')
20+
console.time('Part 2');
21+
let result = part2(data);
22+
console.log('Result:', result);
23+
console.timeEnd('Part 2');
2724
}
2825
}
2926

30-
main()
27+
main();
28+
29+
export function part1(data: string) {}
30+
31+
export function part2(data: string) {}

templates/day/typescript/part-1.ts

-10
This file was deleted.

templates/day/typescript/part-2.ts

-10
This file was deleted.

0 commit comments

Comments
 (0)