Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let smallBottles = +gets(); // 1 liter per bottle
- let bigBottles = +gets(); // 5 liters per bottle
- let capacity = +gets(); // in liters
- let bigBottleLiters = 0;
- let availableSpaceForBigBottles = Math.floor(capacity / 5);
- if(availableSpaceForBigBottles < bigBottles){
- bigBottleLiters = availableSpaceForBigBottles;
- }else{
- bigBottleLiters = bigBottles;
- }
- let bbLiters = bigBottleLiters * 5;
- let availableSpace = capacity - bbLiters;
- // console.log(totalLiters)
- // console.log(availableSpace)
- if(availableSpace <= smallBottles){
- console.log(availableSpace);
- }else{
- console.log('-1');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement