01. Disneyland Journey MID EXAM
function solve(arr) {
let costNeeded = +arr.shift()
let months = +arr.shift()
let sum = 0
let percentage = costNeeded * 0.25
for (let i = 1; i < months; i++) {
let bonus = sum * 0.25
if (i % 4 == 0) {
sum += bonus
}
if (i % 2 == 1 && i >= 2) {
sum -= sum * 0.16
}
sum += percentage
if (sum >= costNeeded) {
console.log(`Bravo! You can go to Disneyland and you will have ${(sum - costNeeded).toFixed(2)}lv. for souvenirs.`)
return
}
}
let more = costNeeded - sum
console.log(`Sorry. You need ${more.toFixed(2)}lv. more.`)
}
Тва е моя код. Дава ми 40 от 100
Задачата е от: Programming Fundamentals Mid Exam Retake - 10 December 2019
https://judge.softuni.bg/Contests/Practice/Index/1958#0
Благодаря!!!
Даде: 100/100
Супер! Моля и честито. :-)
Аз го правя точно както казвате и пак е 40/100
money_need = float(input()) months = int(input()) current_money = 0.00 for m in range(1, months + 1): if m % 2 != 0 and m != 1: current_money *= 0.84 elif m % 4 == 0: current_money *= 1.25 if current_money >= money_need: break current_money += money_need * 0.25 if current_money >= money_need: break if current_money >= money_need: print(f'Bravo! You can go to Disneyland and you will have {current_money - money_need:.2f}lv. for souvenirs.') else: print(f'Sorry. You need {money_need - current_money:.2f}lv. more.')