-
Notifications
You must be signed in to change notification settings - Fork 3
/
boilerplate.ts
68 lines (65 loc) · 2.18 KB
/
boilerplate.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const tests = {
input:
`
`,
first: 1,
second: 0
};
import { intval, log, logList } from "../../tools.ts";
import { puzzle } from "../../puzzle.ts";
const defineSymbols = () => {
const symbols = {};
return symbols;
};
const symbols = defineSymbols();
const scorePart1 = () => {
const scoring = {} as {[key: string]: number};
return scoring;
}
const scoring = scorePart1();
const scorePart2 = () => {
const scoring = {} as {[key: string]: number};
return scoring;
}
const scoring_2 = scorePart2();
const findAnswers = (entries: string[][] | string[][][]) => {
const answers = { first: 0, second: 0 };
log(entries);
return answers;
};
const testPart1 = async (input: string): Promise<boolean> => {
if(tests.first === 0){ return false; }
const puzzle_input = await puzzle.parseInput(input);
const entries = puzzle_input.blocks.length > 0 ? puzzle_input.blocks : puzzle_input.blocks[0];
const answers = findAnswers(entries);
return answers.first === tests.first;
};
const solvePart1 = async (): Promise<number> => {
if(tests.first === 0){ return 0; }
const puzzle_input = await puzzle.parseInput();
const entries = puzzle_input.blocks.length > 0 ? puzzle_input.blocks : puzzle_input.blocks[0];
const answers = findAnswers(entries);
return answers.first;
};
const testPart2 = async (input: string): Promise<boolean> => {
if(tests.second === 0){ return false; }
const puzzle_input = await puzzle.parseInput(input);
const entries = puzzle_input.blocks.length > 0 ? puzzle_input.blocks : puzzle_input.blocks[0];
const answers = findAnswers(entries);
return answers.second === tests.second;
};
const solvePart2 = async (): Promise<number> => {
if(tests.second === 0){ return 0; }
const puzzle_input = await puzzle.parseInput();
const entries = puzzle_input.blocks.length > 0 ? puzzle_input.blocks : puzzle_input.blocks[0];
const answers = findAnswers(entries);
return answers.second;
};
const part1_correct = await testPart1(tests.input);
let check = part1_correct ? '✅' : '❌';
const part1 = await solvePart1();
log(" part 1: ", part1, check);
const part2_correct = await testPart2(tests.input);
check = part2_correct ? '✅' : '❌';
const part2 = await solvePart2();
log(" part 2: ", part2, check);