Retractor
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import * as fs from 'fs';
|
||||
import path from 'path';
|
||||
import {readFile} from "../utils";
|
||||
|
||||
let input = fs.readFileSync(path.resolve(__dirname, './../input/day1/1.txt'), {encoding: "utf-8"}).split("\r\n");
|
||||
let input = readFile(path.resolve(__dirname, 'input.txt'));
|
||||
|
||||
let count = -1;
|
||||
let prev = -1;
|
||||
input.forEach(inp => {
|
||||
input.forEach((inp: any) => {
|
||||
const measure = Number(inp);
|
||||
if (measure > prev) count++;
|
||||
prev = measure;
|
||||
@@ -13,13 +14,10 @@ input.forEach(inp => {
|
||||
|
||||
console.log(count);
|
||||
|
||||
|
||||
input = fs.readFileSync(path.resolve(__dirname, './../input/day1/1.txt'), {encoding: "utf-8"}).split("\r\n");
|
||||
|
||||
let window: any = [];
|
||||
count = -1;
|
||||
prev = -1;
|
||||
input.forEach(inp => {
|
||||
input.forEach((inp: any) => {
|
||||
const measure = Number(inp);
|
||||
|
||||
if (window.length === 3) {
|
||||
5
src/utils/index.ts
Normal file
5
src/utils/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import * as fs from 'fs'
|
||||
|
||||
export const readFile = (file: string): any => {
|
||||
fs.readFileSync(file, {encoding: "utf-8"}).split("\r\n");
|
||||
}
|
||||
Reference in New Issue
Block a user