Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let liliAge = Number(input.shift());
- let washingMachinePrice = Number(input.shift());
- let toyCount = 0;
- let toyPrice = Number(input.shift());
- let sum = 10;
- let totalSum = 0;
- for(let i = 1; i <= liliAge; i++){
- if (i % 2 == 1){
- toyCount++;
- }else{
- totalSum += sum;
- sum += 10;
- totalSum -= 1;
- }
- }
- totalSum += (toyCount * toyPrice)
- let m = totalSum - washingMachinePrice;
- let nn = washingMachinePrice - totalSum;
- if(washingMachinePrice < totalSum){
- console.log(`Yes! ${m.toFixed(2)}`)
- }else{
- console.log(`No! ${nn.toFixed(2)}`)
- }
- }
- solve([21,
- 1570.98,
- 3])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement