Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let input = ['1.92', '5'];
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- let print = this.print || console.log;
- let price = +gets();
- let paid = +gets();
- let result = '';
- let change = (paid - price) * 100;
- let levCount = Math.floor(change / 100);
- change -= levCount * 100;
- let fiftyCount = Math.floor(change / 50);
- change -= fiftyCount * 50;
- let twentyCount = Math.floor(change / 20);
- change -= twentyCount * 20;
- let tenCount = Math.floor(change / 10);
- change -= tenCount * 10;
- let fiveCount = Math.floor(change / 5);
- change -= fiveCount * 5;
- let twoCount = Math.floor(change / 2);
- change -= twoCount * 2;
- let oneCount = Math.floor(change);
- result += levCount ? `${levCount} x 1 lev\n` : '';
- result += fiftyCount ? `${fiftyCount} x 50 stotinki\n` : '';
- result += twentyCount ? `${twentyCount} x 20 stotinki\n` : '';
- result += tenCount ? `${tenCount} x 10 stotinki\n` : '';
- result += fiveCount ? `${fiveCount} x 5 stotinki\n` : '';
- result += twoCount ? `${twoCount} x 2 stotinki\n` : '';
- result += oneCount ? `${oneCount} x 1 stotinka\n` : '';
- print(result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement