jsadvent/solutions/2017/1.js
2020-12-13 00:52:00 -06:00

23 lines
454 B
JavaScript

const { Glib } = require('../../lib');
const VALUE = {
'(': 1,
')': -1,
};
module.exports = {
'1': (input) =>
Glib.fromIterable(input)
.filter((char, index) => char === input[(index + 1n) % input.lengthN])
.toInts()
.sum(),
'2': (input) =>
Glib.fromIterable(input)
.filter(
(char, index) =>
char === input[(index + input.lengthN / 2n) % input.lengthN],
)
.toInts()
.sum(),
};