Advertisement
nikolayneykov

Untitled

Dec 28th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let input = ['1.92', '5'];
  2. let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  3. let print = this.print || console.log;
  4.  
  5. let price = +gets();
  6. let paid = +gets();
  7. let result = '';
  8.  
  9. let change = (paid - price) * 100;
  10.  
  11. let levCount = Math.floor(change / 100);
  12. change -= levCount * 100;
  13.  
  14. let fiftyCount = Math.floor(change / 50);
  15. change -= fiftyCount * 50;
  16.  
  17. let twentyCount = Math.floor(change / 20);
  18. change -= twentyCount * 20;
  19.  
  20. let tenCount = Math.floor(change / 10);
  21. change -= tenCount * 10;
  22.  
  23. let fiveCount = Math.floor(change / 5);
  24. change -= fiveCount * 5;
  25.  
  26. let twoCount = Math.floor(change / 2);
  27. change -= twoCount * 2;
  28.  
  29. let oneCount = Math.floor(change);
  30.  
  31. result += levCount ? `${levCount} x 1 lev\n` : '';
  32. result += fiftyCount ? `${fiftyCount} x 50 stotinki\n` : '';
  33. result += twentyCount ? `${twentyCount} x 20 stotinki\n` : '';
  34. result += tenCount ? `${tenCount} x 10 stotinki\n` : '';
  35. result += fiveCount ? `${fiveCount} x 5 stotinki\n` : '';
  36. result += twoCount ? `${twoCount} x 2 stotinki\n` : '';
  37. result += oneCount ? `${oneCount} x 1 stotinka\n` : '';
  38.  
  39. print(result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement