georgiev955

06. Oscars

Feb 25th, 2023
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let actorName = input.shift();
  3.     let academyScore = Number(input.shift());
  4.     let juryCount = Number(input.shift());
  5.     let index = 0;
  6.     let currentJuryName = input[index];
  7.     index++;
  8.     let currentJuryPoints = input[index];
  9.     index++;
  10.     let result = 0;
  11.     for (let i = 0; i < juryCount; i++) {
  12.         let pointsFromName = Number(currentJuryName.length);
  13.         result += pointsFromName*currentJuryPoints/2;
  14.         academyScore += result;
  15.         if (academyScore > 1250.5) {
  16.             console.log(`Congratulations, ${actorName} got a nominee for leading role with ${(academyScore).toFixed(1)}!`);
  17.             return;
  18.         }
  19.         result = 0;
  20.         currentJuryName = input[index];
  21.         index++;
  22.         currentJuryPoints = input[index];
  23.         index++;
  24.     }
  25.     if (academyScore <= 1250.5) {
  26.         console.log(`Sorry, ${actorName} you need ${(1250.5-academyScore).toFixed(1)} more!`)
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment