Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let pattern = /::([A-Z][a-z]{2,})::|\*\*([A-Z][a-z]{2,})\*\*/g;
  3.  
  4.     let matches = 0;
  5.  
  6.     for (let line of input) {
  7.         let matches = line.match(pattern);
  8.     }
  9.  
  10.     let decimalPattern = /\d/g;
  11.  
  12.     let treshold = 0;
  13.  
  14.     decimalPattern.forEach(element => {
  15.         treshold += Number(element);
  16.     });
  17.  
  18.     let coolEmojCount = 0;
  19.     let coolEmojis = 0;
  20.  
  21.     for (const match of matches) {
  22.         let sum = 0;
  23.         for(let i = 0; i < match.length; i++) {
  24.              sum += match.charCodeAt(i);
  25.         }
  26.  
  27.         if (sum > treshold) {
  28.             coolEmojCount++;
  29.             coolEmojis.push(match);
  30.         }
  31.     }
  32.  
  33.     Console.log('Cool treshold: $n$coolEmojiCount');
  34.     Console.log('$matches.count() emojis found in the text. The cool ones are:%n')
  35.     for (const iterator of coolEmojis) {
  36.         Console.log(iterator);
  37.     }
  38.    
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement