23 lines
449 B
JavaScript
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(),
|
|
};
|