From 7bab2084ebd5a04b1d887b929ee9677ac85b4c5d Mon Sep 17 00:00:00 2001 From: Tristan Date: Wed, 2 Jan 2019 01:12:02 +0000 Subject: [PATCH] fixed some file bugs --- .gitignore | 3 ++- 2015/01/part1.py | 5 ++++- 2015/01/part2.py | 5 ++++- 2015/03/part1.py | 5 ++++- 2018/04/part1.js | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 9a0a6e6..c0fe2ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build frames -.DS_Store \ No newline at end of file +.DS_Store +.vscode \ No newline at end of file diff --git a/2015/01/part1.py b/2015/01/part1.py index b5387c7..8144159 100644 --- a/2015/01/part1.py +++ b/2015/01/part1.py @@ -1,4 +1,7 @@ -with open('input.txt', 'r') as input: +import os +path = os.path.dirname(os.path.abspath(__file__)) + +with open(path+'/input.txt', 'r') as input: counter = 0 text = input.readline() for char in text : diff --git a/2015/01/part2.py b/2015/01/part2.py index 784c2ce..55af729 100644 --- a/2015/01/part2.py +++ b/2015/01/part2.py @@ -1,4 +1,7 @@ -with open('input.txt', 'r') as input: +import os +path = os.path.dirname(os.path.abspath(__file__)) + +with open(path+'/input.txt', 'r') as input: pos = 0 char_pos = 0 text = input.readline() diff --git a/2015/03/part1.py b/2015/03/part1.py index 4dac7f5..8a873f1 100644 --- a/2015/03/part1.py +++ b/2015/03/part1.py @@ -1,4 +1,7 @@ -with open("input.txt", "r") as commands: +import os +path = os.path.dirname(os.path.abspath(__file__)) + +with open(path+"/input.txt", "r") as commands: x = 0 y = 0 history = [] diff --git a/2018/04/part1.js b/2018/04/part1.js index 72012cf..ca4c352 100644 --- a/2018/04/part1.js +++ b/2018/04/part1.js @@ -1,6 +1,6 @@ const fs = require('fs'); -let input = fs.readFileSync('input.txt', 'utf-8').split('\n').sort((a, b) => val(a).getTime() - val(b).getTime()); +let input = fs.readFileSync(`${__dirname}/input.txt`, 'utf-8').split('\n').sort((a, b) => val(a).getTime() - val(b).getTime()); function val(a) { let time = new Date(a.match(/\[(.*)\]/)[1]);