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