Skip to content

Commit 3fd5ae2

Browse files
Small fix
1 parent 38139bb commit 3fd5ae2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

2017/day5/solution.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
console.time("Day 5b");
12
const { input } = require('./input.js');
23

34
const inputArray = input.split('\n');
@@ -17,8 +18,12 @@ const recursiveCalculateJumpsToExit = (input, steps, index, modifyJump) => {
1718
let jump = +input[index];
1819
input[index] = modifyJump(jump);
1920
steps++;
20-
return (index < input.length) ? calculateJumpsToExit(input, steps, index + jump, modifyJump) : steps;
21+
return (index < input.length) ? recursiveCalculateJumpsToExit(input, steps, index + jump, modifyJump) : steps;
2122
}
2223

23-
//console.log(calculateJumpsToExit(inputArray, 0, 0, (value) => ++value));
24-
console.log(recursiveCalculateJumpsToExit(inputArray, 0, 0, (value) => value > 2 ? --value : ++value));
24+
25+
const output = calculateJumpsToExit(inputArray, 0, 0, (value) => value > 2 ? --value : ++value);
26+
console.timeEnd("Day 5b");
27+
28+
//console.log(calculateJumpsToExit(inputArray, 0, 0, (value) => ++value)); // Day 5a
29+
console.log(output);

0 commit comments

Comments
 (0)