jsadvent/solutions/2017/1.js
2020-12-10 02:33:00 -06:00

23 lines
449 B
JavaScript

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