Compare commits

...

2 Commits

Author SHA1 Message Date
Eric Wagoner
8223e82097 Day one, part one 2025-12-01 11:08:54 -05:00
Eric Wagoner
3e11588b2e Tweak templates 2025-12-01 11:06:33 -05:00
5 changed files with 38 additions and 28 deletions

View File

@@ -1,22 +1,35 @@
import { readFileSync } from 'node:fs'; import { readFileSync } from 'node:fs';
const inputArray = readFileSync('sample.txt').toString().split("\n"); // const inputArray = readFileSync('sample.txt').toString().split("\n");
// const inputArray = fs.readFileSync('input.txt').toString().split("\n"); const inputArray = readFileSync('input.txt').toString().split("\n");
// Part One // Part One
for (i in inputArray) { let zeroCount = 0;
const contents = inputArray[i].split(" "); let currentPosition = 50;
for (const element of inputArray) {
const instruction = element;
const direction = instruction[0];
const steps = Number.parseInt(instruction.slice(1));
if (direction === 'L') {
currentPosition -= steps;
} else {
currentPosition += steps;
}
if (currentPosition === 0 || (currentPosition % 100) === 0) {
zeroCount++;
}
} }
console.log(); console.log(zeroCount);
// Part Two // Part Two
for (i in inputArray) { for (const element of inputArray) {
const contents = inputArray[i].split(" ");
} }

View File

@@ -1,12 +1,12 @@
import { readFileSync } from 'node:fs'; import { readFileSync } from 'node:fs';
const inputArray = readFileSync('sample.txt').toString().split("\n"); const inputArray = readFileSync('sample.txt').toString().split("\n");
// const inputArray = fs.readFileSync('input.txt').toString().split("\n"); // const inputArray = readFileSync('input.txt').toString().split("\n");
// Part One // Part One
for (i in inputArray) { for (const element of inputArray) {
const contents = inputArray[i].split(" "); const contents = element.split(" ");
} }
@@ -15,13 +15,11 @@ console.log();
// Part Two // Part Two
for (i in inputArray) { for (const element of inputArray) {
const contents = inputArray[i].split(" "); const contents = element.split(" ");
} }
console.log(); console.log();
// functions // functions

View File

@@ -1,12 +1,12 @@
import { readFileSync } from 'node:fs'; import { readFileSync } from 'node:fs';
const inputArray = readFileSync('sample.txt').toString().split("\n"); const inputArray = readFileSync('sample.txt').toString().split("\n");
// const inputArray = fs.readFileSync('input.txt').toString().split("\n"); // const inputArray = readFileSync('input.txt').toString().split("\n");
// Part One // Part One
for (i in inputArray) { for (const element of inputArray) {
const contents = inputArray[i].split(" "); const contents = element.split(" ");
} }
@@ -15,13 +15,11 @@ console.log();
// Part Two // Part Two
for (i in inputArray) { for (const element of inputArray) {
const contents = inputArray[i].split(" "); const contents = element.split(" ");
} }
console.log(); console.log();
// functions // functions

View File

@@ -1,12 +1,12 @@
import { readFileSync } from 'node:fs'; import { readFileSync } from 'node:fs';
const inputArray = readFileSync('sample.txt').toString().split("\n"); const inputArray = readFileSync('sample.txt').toString().split("\n");
// const inputArray = fs.readFileSync('input.txt').toString().split("\n"); // const inputArray = readFileSync('input.txt').toString().split("\n");
// Part One // Part One
for (i in inputArray) { for (const element of inputArray) {
const contents = inputArray[i].split(" "); const contents = element.split(" ");
} }
@@ -15,13 +15,11 @@ console.log();
// Part Two // Part Two
for (i in inputArray) { for (const element of inputArray) {
const contents = inputArray[i].split(" "); const contents = element.split(" ");
} }
console.log(); console.log();
// functions // functions

3
package.json Normal file
View File

@@ -0,0 +1,3 @@
{
"type": "module"
}