-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path7.js
More file actions
27 lines (21 loc) · 666 Bytes
/
7.js
File metadata and controls
27 lines (21 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
let getResult = (data) => {
let parse_ints = str => {
return str.split(' ').filter(val => val != '').map(val => parseInt(val.trim()));
}
let count = parseInt(data[0]);
let nulled = [];
for(let i = 1; i <= count; i++) {
let arr = parse_ints(data[i]);
if (arr[0] === 0) {
nulled.push(i);
}
}
return nulled.reduce((acc, val) => acc+=val);
}
//console.log('start: ' + Date.now());
const fs = require('fs');
let fileContent = fs.readFileSync("input.txt", "utf8");
const data = fileContent.toString().trim().split("\n");
const result = getResult(data);
fs.writeFileSync("output.txt", result.toString());
//console.log('end: ' + Date.now());