Advertisement
Guest User

Untitled

a guest
Jan 29th, 2019
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(array1) {
  2.  
  3.     let array = array1.slice(0, 999);
  4.     let dayCounter = 0;
  5.     let totalGold = 0;
  6.     let money = 0;
  7.     let bitcoins = 0;
  8.     let moneyLeft = 0;
  9.     let firstCoinDay = 0;
  10.     let bool = true;
  11.     array.forEach(func);
  12.  
  13.     function func(gold, index) {
  14.         dayCounter = index + 1;
  15.         if (dayCounter % 3 == 0) {
  16.             gold = gold * 0.7;
  17.         }
  18.         totalGold += gold;
  19.         money = totalGold * 67.51;
  20.  
  21.         if (money >= 11949.16 && bool == true) {
  22.             firstCoinDay = dayCounter;
  23.             bool = false;
  24.         }
  25.     }
  26.     bitcoins = Math.floor(money / 11949.16);
  27.     moneyLeft = (money % 11949.16).toFixed(2);
  28.  
  29.     console.log(`Bought bitcoins: ${bitcoins}`);
  30.     if (bitcoins > 0) {
  31.         console.log(`Day of the first purchased bitcoin: ${firstCoinDay}`);
  32.     }
  33.     console.log(`Left money: ${moneyLeft} lv.`);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement