Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let digitArr = []
- let coolEmojies = []
- let count = 0
- let threshold = 0
- input.map(x => {
- //let pattern = /([:|\*]{2})(?<emos>[A-Z][a-z]{2,})(\1)/g
- let pattern = /(\*{2}|:{2})(?<emos>[A-Z][a-z]{2,})(\1)/g
- const patternLetters = /[a-zA-Z]/g;
- let digits = /\d/g
- //let line = pattern.exec(x);
- let line = x.match(pattern)
- let finalDigits = x.match(digits)
- digitArr.push(finalDigits)
- digitArr.map(x => {
- threshold = x.map(Number).reduce((a, v) => a * v)
- })
- // if(line){
- // count++
- // let emojis = line.groups.emos emojis = emojis.match(patternLetters).map(y => y.charCodeAt())
- for (i = 0; i < line.length; i++) {
- let emojis = line[i]
- emojis = emojis.match(patternLetters).map(y => y.charCodeAt())
- // let sumOfChars = emojis.map(Number).reduce((a, v) => a * v)
- let sumOfChars = emojis.map(Number).reduce((a, v) => a + v)
- if (sumOfChars > threshold) {
- //coolEmojies.push(line[0]);
- coolEmojies.push(line[i]);
- }
- }
- console.log(`Cool threshold: ${threshold}`)
- //console.log(`${count} emojis found in the text. The cool ones are:`);
- console.log(`${line.length} emojis found in the text. The cool ones are:`);
- console.log(coolEmojies.join("\n"));
- // }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement