···11-// In our parent folder, we have a text file, input.txt, with lines of strings we want to store in an array.
22-import {readFileSync} from 'node:fs';
33-44-// Read the file and split it into an array of strings
55-const input: string[] = readFileSync('src/day1/input.txt', 'utf8').split('\n');
66-77-(() => { // Part A
11+export const partA = (input: string[]) => { // Part A
82 const calibrationValue = (line: string) => {
93 // Slice the first and last digits from the string and combine them into a number
104 // The first digit might be anywhere in the string, so we need to find it
···2014 sum += calibrationValue(line);
2115 }
22162323- console.log(sum);
2424- // Answer: 55029
2525-})();
1717+ return sum; // Answer: 55029
1818+};
26192727-(() => { // Part B
2020+export const partB = (input: string[]) => { // Part B
2821 const calibrationValue = (line: string): number => {
2922 // Let's find all possible numbers in the string.
3023 // For each character, if it's a digit, we'll add it to our ordered list of digits.
···109102 sum += getValue;
110103 }
111104112112- console.log(sum);
113113- // Answer: 55686
114114-})();
105105+ return sum; // Answer: 55686
106106+};