Created
December 7, 2020 14:59
-
-
Save kimagure44/bd557ac160774b570a24f9ccd321356d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
const entries = (await(await fetch('https://adventofcode.com/2020/day/6/input')).text()).split('\n').map(item => item); | |
const startTime = performance.now(); | |
let arr = []; | |
let total = []; | |
entries.forEach(item => { | |
if (item.length > 0) { | |
arr.push(Array.from(item).sort((a, b) => a > b ? 1 : -1)); | |
} else { | |
const totalSet = new Set(arr.flat()); | |
total.push({ arr: totalSet, size: totalSet.size }); | |
arr = []; | |
} | |
}); | |
let recuento = 0; | |
total.forEach(item => { | |
console.log(item); | |
recuento += item.size; | |
}); | |
const endTime = performance.now(); | |
console.log(recuento, `${parseFloat(endTime - startTime).toFixed(4)} ms`); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment