renamed 2 digit file names
This commit is contained in:
parent
018011dd27
commit
b4d985a55a
44 changed files with 0 additions and 0 deletions
20
2018/03/part1.js
Normal file
20
2018/03/part1.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
const fs = require('fs');
|
||||
|
||||
let input = fs.readFileSync('input.txt', 'utf-8');
|
||||
let grid = {};
|
||||
|
||||
for (const line of input.split('\n')) {
|
||||
[rule,
|
||||
id,
|
||||
left,
|
||||
top,
|
||||
width,
|
||||
height] = line.match(/#(\d+) @ (\d+),(\d+): (\d+)x(\d+)/).map(Number);
|
||||
for (let x = left; x < left + width; x++) {
|
||||
for (let y = top; y < top + height; y++) {
|
||||
grid[`${x},${y}`] = (grid[`${x},${y}`] || 0) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(Object.values(grid).filter(v => v > 1).length);
|
Loading…
Add table
Add a link
Reference in a new issue