Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 28th, 2020 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let food = Number(input.shift()) * 1000
  3.     let eatenFood = 0;
  4.  
  5.     while (input[0] != 'Adopted') {
  6.         eatenFood += Number(input.shift())
  7.     }
  8.  
  9.     if (food >= eatenFood) {
  10.         console.log(`Food is enough! Leftovers: ${food - eatenFood} grams.`)
  11.     } else {
  12.         console.log(`Food is not enough. You need ${eatenFood - food} grams more.`)
  13.     }
  14. }
  15. solve([
  16.     2,
  17.     999,
  18.     456,
  19.     999,
  20.     999,
  21.     123,
  22.     456,
  23.     'Adopted'
  24. ])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top