Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(args) {
- const bitcoin = 11949.16;
- const gold = 67.51;
- let totalSum = 0;
- let day = 0;
- let firstDay = 0;
- let boughtBitcoin = 0;
- let countBitcoin = 0;
- let sumBitcoins = 0;
- args.forEach((element) => {
- day++;
- if (day % 3 === 0) {
- element *= 0.7;
- }
- const singleDayEarning = element * gold;
- totalSum += singleDayEarning;
- if (totalSum >= bitcoin) {
- countBitcoin++;
- boughtBitcoin = Math.floor(totalSum / bitcoin);
- totalSum -= (bitcoin * boughtBitcoin);
- sumBitcoins += boughtBitcoin;
- }
- if (countBitcoin === 1) {
- firstDay = day;
- }
- });
- console.log(`Bought bitcoins: ${sumBitcoins}`);
- if (firstDay !== 0) {
- console.log(`Day of the first purchased bitcoin: ${firstDay}`);
- }
- console.log(`Left money: ${totalSum.toFixed(2)} lv.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement