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jsqqcsdfGdcp\nHLzZfHWWQwpgVHjVHr\nJlMlMGGDMtJGdtJhqtlccDgVCSTFFSCSDTggpvFTjSgS\nJcGRMlthtlVNMJRfzWsPnQsnnZNZns\nzVfvMpsbtQmtBlFWBZ\nlLSrlNTNRSFRFhhHRmPR\ndnSJjjwJJGwwnzVlvpszvccM\nSmlcCrpnrnznGzSBBSfzNbtsQsWZQcFbWctcbbZb\nJHgwJPjvdghbbWdDZGNLZb\nJjghvvhRwhwJVhHTzmfRfzGSMrzBfnGC\nJbCmrbnzmntnVJjbCHJJFQFvqgJgQgqLDQ\nNGhhhhPMGhWsSSchWlNsCLBBlLFQCgqvgCFFgQBg\nPdcNWWcdGdPssPPNTSNNtzbTwjntzbbVwtZpCVnb\ntGNgtsNQHsJmwwzddmQw\nhMhhDBwMhDDfCRRBjFDDTTWjdWmrmdWqjlmmmjJz\nRSpSSBhppDhRncRLswZLGvtGvNcNtL";
|
|
|
|
const getValue = (char) => {
|
|
const code = char.charCodeAt(0);
|
|
if(code < 92) {
|
|
return code - 38;
|
|
}
|
|
return code - 96;
|
|
}
|
|
|
|
const main = async () => {
|
|
const sacks = input.split("\n").map( r => r.split(''));
|
|
const compartments = sacks.map(sack => [sack.slice(0, (sack.length + 1)/2), sack.slice((sack.length+1)/2)]);
|
|
const doubles = compartments.map(([comp1, comp2]) => comp1.find(c => comp2.includes(c)));
|
|
return doubles.map(getValue).reduce((sum, a) => sum + a, 0);
|
|
|
|
};
|
|
|
|
|
|
main().then(r => console.log("Result: ", r));
|