Skip to content

Instantly share code, notes, and snippets.

@magalhini
Created December 3, 2015 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magalhini/3979dce9039e2227bae9 to your computer and use it in GitHub Desktop.
Save magalhini/3979dce9039e2227bae9 to your computer and use it in GitHub Desktop.
Advent O fCode
const fs = require('fs');
const file = fs.readFileSync('./1.txt').toString('utf8');
let level = 0;
let findWay = (char) => {
if (char === '(') return 1;
else if (char === ')') return -1;
}
for (let char of file) {
level += findWay(char);
}
console.log('Final level is:', level);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment