Skip to content

Commit ef857c6

Browse files
day1 part1 also in crystal
1 parent 2ad2da5 commit ef857c6

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

day1/crystal/part1.cr

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
input = File.read("../day1.input")
2+
inputArr = input.split("\n")
3+
4+
noi = 0
5+
index = 1
6+
7+
while index < inputArr.size
8+
el = inputArr[index].to_i
9+
prevEl = inputArr[index - 1].to_i
10+
noi += 1 if el > prevEl
11+
index += 1
12+
end
13+
14+
puts noi

day1/part1.js renamed to day1/javascript/part1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const fs = require('fs')
22

3-
const input = fs.readFileSync('./day1.input').toString()
3+
const input = fs.readFileSync('../day1.input').toString()
44
const inputArr = input.split("\n").map((e) => parseInt(e));
55

66
let numberOfIncrements = 0;

day1/part2.js renamed to day1/javascript/part2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const fs = require('fs')
22

3-
const input = fs.readFileSync('./day1.input').toString()
3+
const input = fs.readFileSync('../day1.input').toString()
44
const inputArr = input.split("\n").map((e) => parseInt(e));
55

66
const chunk = 3;

0 commit comments

Comments
 (0)