Vassil_Iliev

oscars diff

Mar 3rd, 2022
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///// 60 points
  2.  
  3. function oscars(input) {
  4.     let actorName = input[0];
  5.     let academyPoints = +input[1];
  6.     let countOfJury = +input[2];
  7.     let points = academyPoints;
  8.     let juryNamesArr = [];
  9.     let pointsArr = [];
  10.  
  11.     for (let i = 1; i <= countOfJury + countOfJury; i++) {
  12.         if (i % 2 != 0) {
  13.             juryNamesArr.push(input[i + 2])
  14.         }
  15.     }
  16.  
  17.     for (let i = 1; i <= countOfJury + countOfJury; i++) {
  18.         if (i % 2 != 0) {
  19.             pointsArr.push(input[i + 3])
  20.         }
  21.     }
  22.  
  23.     for (let i = 0; i < pointsArr.length; i++) {
  24.         if (points.toFixed(1) > 1250.5) {
  25.             console.log(`Congratulations, ${actorName} got a nominee for leading role with ${points.toFixed(1)}!`);
  26.             break;
  27.         }
  28.         points += (pointsArr[i] * juryNamesArr[i].length) / 2;
  29.     }
  30.     if (points < 1250.5) {
  31.         console.log(`Sorry, ${actorName} you need ${(Math.abs(points - 1250.5)).toFixed(1)} more!`);
  32.     }
  33.  
  34. }
  35.  
  36.  
  37.  
  38.  
  39. ///// 100 points
  40.  
  41. function oscars(input) {
  42.     let actorName = input[0];
  43.     let academyPoints = +input[1];
  44.     let countOfJury = +input[2];
  45.     let points = academyPoints;
  46.     let juryNamesArr = [];
  47.     let pointsArr = [];
  48.  
  49.     for (let i = 1; i <= countOfJury + countOfJury; i++) {
  50.         if (i % 2 != 0) {
  51.             juryNamesArr.push(input[i + 2])
  52.         }
  53.     }
  54.  
  55.     for (let i = 1; i <= countOfJury + countOfJury; i++) {
  56.         if (i % 2 != 0) {
  57.             pointsArr.push(input[i + 3])
  58.         }
  59.     }
  60.  
  61.     for (let i = 0; i < pointsArr.length; i++) {
  62.        
  63.         points += (pointsArr[i] * juryNamesArr[i].length) / 2;
  64.  
  65.  if (points.toFixed(1) > 1250.5) {
  66.             console.log(`Congratulations, ${actorName} got a nominee for leading role with ${points.toFixed(1)}!`);
  67.             break;
  68.         }
  69.     }
  70.     if (points < 1250.5) {
  71.         console.log(`Sorry, ${actorName} you need ${(Math.abs(points - 1250.5)).toFixed(1)} more!`);
  72.     }
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment