SHARE
TWEET

Untitled

a guest Sep 21st, 2017 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(args) {
  2.  
  3.     const nN = +args[0];
  4.     const mM = +args[nN + 1];
  5.     let pricelist = {};
  6.     var rowValue = 0;
  7.     let daString = args.slice(nN + 2).join(', nababatihvarchiloto, ') + ', nababatihvarchiloto';
  8.     let elementArr = daString.split(', ');
  9.  
  10.     for (let k = 1; k < (nN + 1); k += 1) {
  11.  
  12.         let element = args[k].split(' ');
  13.         let price = parseFloat(element.pop());
  14.         let name = element.join(' ');
  15.         pricelist[name] = price;
  16.     }
  17.     for (let ind = 0; ind <= elementArr.length; ind += 1) {
  18.  
  19.         var a = elementArr[ind];
  20.         var b = parseInt(a);
  21.         if (a === 'nababatihvarchiloto') {
  22.             console.log(rowValue.toFixed(2));
  23.             rowValue = 0;
  24.             continue;
  25.         }
  26.  
  27.         if (isNaN(b)) {
  28.             rowValue += pricelist[a];
  29.         } else {
  30.             // var sss = elementArr[ind].indexOf(' ');
  31.             // var vvv = a.slice((elementArr[ind].indexOf(' '))+1);
  32.            
  33.             rowValue += b * pricelist[a.slice((elementArr[ind].indexOf(' '))+1)];
  34.         }
  35.  
  36.     }
  37.  
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top