Advertisement
Spocoman

10. Profit

Jan 1st, 2022
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function profit(input) {
  2.     let oneBGN = Number(input[0]);
  3.     let twoBGN = Number(input[1]);
  4.     let fiveBGN = Number(input[2]);
  5.     let sum = Number(input[3]);
  6.  
  7.     for (let i = 0; i <= oneBGN; i++) {
  8.         for (let j = 0; j <= twoBGN; j++) {
  9.             for (let k = 0; k <= fiveBGN; k++) {
  10.                 if (i * 1 + j * 2 + k * 5 === sum) {
  11.                     console.log(`${i} * 1 lv. + ${j} * 2 lv. + ${k} * 5 lv. = ${sum} lv.`);
  12.                 }
  13.             }
  14.         }
  15.     }
  16. }
  17.  
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement