-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathinput.js
More file actions
32 lines (29 loc) · 686 Bytes
/
input.js
File metadata and controls
32 lines (29 loc) · 686 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
28
29
30
31
32
const path = require('path');
const fs = require('fs');
const strsToInts = (...nums) => nums.map((n) => parseInt(n, 10));
/**
* @example [[1, 2, 3], [-1, -2, -3], ...]
*/
const input = fs
.readFileSync(path.join(__dirname, 'input.txt'), 'utf8')
.toString()
.trim()
.split('\n')
.map((line) => {
// @example <x=-16, y=-1, z=-12>
let [, x, y, z] = /^\<x=(-?\d+), y=(-?\d+), z=(-?\d+)\>$/.exec(line);
[x, y, z] = strsToInts(x, y, z);
return [x, y, z];
});
module.exports = {
sampleInput: {
positions: [
[-8, -10, 0],
[5, 5, 10],
[2, -7, 3],
[9, -8, -3],
],
energy: 1940, // After 100 steps, (29 * 10) + (32 * 19) + (41 * 14) + (52 * 9)
},
input,
};