2020-12-10 08:33:00 +00:00
|
|
|
const { Glib } = require('../../lib');
|
|
|
|
|
|
|
|
const VALUE = {
|
|
|
|
'(': 1,
|
|
|
|
')': -1,
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
'1': (input) =>
|
|
|
|
Glib.fromIterable(input)
|
2020-12-13 06:52:00 +00:00
|
|
|
.filter((char, index) => char === input[(index + 1n) % input.lengthN])
|
2020-12-10 08:33:00 +00:00
|
|
|
.toInts()
|
|
|
|
.sum(),
|
|
|
|
'2': (input) =>
|
|
|
|
Glib.fromIterable(input)
|
|
|
|
.filter(
|
|
|
|
(char, index) =>
|
2020-12-13 06:52:00 +00:00
|
|
|
char === input[(index + input.lengthN / 2n) % input.lengthN],
|
2020-12-10 08:33:00 +00:00
|
|
|
)
|
|
|
|
.toInts()
|
|
|
|
.sum(),
|
|
|
|
};
|