jsadvent/solutions/2017/1.js

23 lines
449 B
JavaScript
Raw Normal View History

2020-12-10 08:33:00 +00:00
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(),
};