Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Hotel Hosting Costs by PythonLearner
def hotel_cost(rate: int, incr: int, day: int) -> int:
month_days = 31
stop_day = 15
days = month_days - day + 1
increasing_days = day if day < stop_day else stop_day
dayly_rate = rate + incr * (increasing_days - 1)
return days * dayly_rate
print("Example:")
print(hotel_cost(3, 2, 1))
# These "asserts" are used for self-checking
assert hotel_cost(100, 10, 1) == 3100
assert hotel_cost(100, 20, 15) == 6460
assert hotel_cost(100, 5, 16) == 2720
assert hotel_cost(150, 10, 15) == 4930
assert hotel_cost(200, 25, 31) == 550
assert hotel_cost(50, 5, 2) == 1650
print("The mission is done! Click 'Check Solution' to earn rewards!")
Feb. 21, 2026