generated from eric/adventofcode2023
Compare commits
2 Commits
90378ddd6f
...
8223e82097
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8223e82097 | ||
|
|
3e11588b2e |
27
01/code.js
27
01/code.js
@@ -1,22 +1,35 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const inputArray = readFileSync('sample.txt').toString().split("\n");
|
||||
// const inputArray = fs.readFileSync('input.txt').toString().split("\n");
|
||||
// const inputArray = readFileSync('sample.txt').toString().split("\n");
|
||||
const inputArray = readFileSync('input.txt').toString().split("\n");
|
||||
|
||||
// Part One
|
||||
|
||||
for (i in inputArray) {
|
||||
const contents = inputArray[i].split(" ");
|
||||
let zeroCount = 0;
|
||||
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
|
||||
|
||||
for (i in inputArray) {
|
||||
const contents = inputArray[i].split(" ");
|
||||
for (const element of inputArray) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
12
02/code.js
12
02/code.js
@@ -1,12 +1,12 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
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
|
||||
|
||||
for (i in inputArray) {
|
||||
const contents = inputArray[i].split(" ");
|
||||
for (const element of inputArray) {
|
||||
const contents = element.split(" ");
|
||||
|
||||
}
|
||||
|
||||
@@ -15,13 +15,11 @@ console.log();
|
||||
|
||||
// Part Two
|
||||
|
||||
for (i in inputArray) {
|
||||
const contents = inputArray[i].split(" ");
|
||||
for (const element of inputArray) {
|
||||
const contents = element.split(" ");
|
||||
|
||||
}
|
||||
|
||||
|
||||
console.log();
|
||||
|
||||
// functions
|
||||
|
||||
|
||||
12
03/code.js
12
03/code.js
@@ -1,12 +1,12 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
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
|
||||
|
||||
for (i in inputArray) {
|
||||
const contents = inputArray[i].split(" ");
|
||||
for (const element of inputArray) {
|
||||
const contents = element.split(" ");
|
||||
|
||||
}
|
||||
|
||||
@@ -15,13 +15,11 @@ console.log();
|
||||
|
||||
// Part Two
|
||||
|
||||
for (i in inputArray) {
|
||||
const contents = inputArray[i].split(" ");
|
||||
for (const element of inputArray) {
|
||||
const contents = element.split(" ");
|
||||
|
||||
}
|
||||
|
||||
|
||||
console.log();
|
||||
|
||||
// functions
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
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
|
||||
|
||||
for (i in inputArray) {
|
||||
const contents = inputArray[i].split(" ");
|
||||
for (const element of inputArray) {
|
||||
const contents = element.split(" ");
|
||||
|
||||
}
|
||||
|
||||
@@ -15,13 +15,11 @@ console.log();
|
||||
|
||||
// Part Two
|
||||
|
||||
for (i in inputArray) {
|
||||
const contents = inputArray[i].split(" ");
|
||||
for (const element of inputArray) {
|
||||
const contents = element.split(" ");
|
||||
|
||||
}
|
||||
|
||||
|
||||
console.log();
|
||||
|
||||
// functions
|
||||
|
||||
|
||||
3
package.json
Normal file
3
package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
Reference in New Issue
Block a user