Advertisement
Guest User

SmartLili

a guest
Jun 19th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let liliAge = Number(input.shift());
  3.     let washingMachinePrice = Number(input.shift());
  4.     let toyCount = 0;
  5.     let toyPrice = Number(input.shift());
  6.     let sum = 10;
  7.     let totalSum = 0;
  8.     for(let i = 1; i <= liliAge; i++){
  9.         if (i % 2 == 1){
  10.           toyCount++;
  11.         }else{
  12.           totalSum += sum;
  13.           sum += 10;
  14.           totalSum -= 1;
  15.         }
  16.        
  17.     }
  18.     totalSum += (toyCount * toyPrice)
  19.     let m = totalSum - washingMachinePrice;
  20.     let nn = washingMachinePrice - totalSum;
  21.     if(washingMachinePrice < totalSum){
  22.         console.log(`Yes! ${m.toFixed(2)}`)
  23.     }else{
  24.         console.log(`No! ${nn.toFixed(2)}`)
  25.     }
  26. }
  27. solve([21,
  28.     1570.98,
  29.     3])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement