summaryrefslogtreecommitdiffstats
path: root/day3/day3-2.js
blob: a0c558deb680de7063a3f23823364d9d3137b066 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
const data = require('./data')
const check = (x, y) => {
  let trees = 0, turn = 0;
  for(i=0; i<data.length; i=i+y) {
    turn !== 0 && data[i][(x * turn)%data[i].length] === "#" && (trees += 1)
    turn += 1
  }
  return trees
}

console.log(check(1,1) * check(3,1) * check(5,1) * check(7,1) * check(1,2))