Advertisement
Pijomir

Bitcoin "Mining"

Aug 5th, 2022
1,358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bitcoinMining(input) {
  2.  
  3.     let btc = 0;
  4.     let firstBtcDay = 0;
  5.     let confirmFirstDay = 0;
  6.     let money = 0;
  7.     let btcIntoBgn = 11949.16;
  8.  
  9.     for (let i = 1; i <= input.length; i++) {
  10.  
  11.         let currentMinedMoney = Number(input[i - 1]) * 67.51;
  12.  
  13.         i % 3 === 0 ? money += currentMinedMoney * 0.7 : money += currentMinedMoney;
  14.  
  15.         if (money >= btcIntoBgn) {
  16.             btc += Math.floor(money / btcIntoBgn);
  17.             money = money % btcIntoBgn;
  18.             confirmFirstDay++;
  19.         }
  20.  
  21.         if (confirmFirstDay === 1) {
  22.             firstBtcDay = i;
  23.         }
  24.     }
  25.    
  26.     console.log(`Bought bitcoins: ${btc}`);
  27.     if (btc > 0) {
  28.         console.log(`Day of the first purchased bitcoin: ${firstBtcDay}`);
  29.     }
  30.     console.log(`Left money: ${money.toFixed(2)} lv.`);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement