Skip to content

Instantly share code, notes, and snippets.

@magalhini
Created December 3, 2015 16:17
Show Gist options
  • Select an option

  • Save magalhini/3979dce9039e2227bae9 to your computer and use it in GitHub Desktop.

Select an option

Save magalhini/3979dce9039e2227bae9 to your computer and use it in GitHub Desktop.

Revisions

  1. magalhini created this gist Dec 3, 2015.
    15 changes: 15 additions & 0 deletions advent-day1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    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);