'YOUR TESTS TIMED OUT' in Python 'Currency Exchange' exercise?

I don’t understand what the issue is since it’s a simple, short & functional block of code that runs perfectly fine in VS Code but every time I run it, I get that 'YOUR TESTS TIMED OUT" error.
Thanks for any tips on how to resolve this.

def exchangeable_value(budget, exchange_rate, spread, denomination):

    """

    :param budget: float - the amount of your money you are planning to exchange.
    :param exchange_rate: float - the unit value of the foreign currency.
    :param spread: int - percentage that is taken as an exchange fee.
    :param denomination: int - the value of a single bill.
    :return: int - maximum value you can get.
    """
       
    i = 1
    total = denomination * exchange_rate + (exchange_rate * spread) / 100
    while budget >= i * total:
        i += 1
    return ((i - 1) * total) 

I have seen this before and the problem was, that the method is too slow for the online test-runner. You might be able to speed up your method. Look at the last test case for a reference time.

Sorry, I didn’t understand that?
Still…that is an incredibly weak test-runner if this code is considered to be too slow!?

Imagine if the number of bills is 5_738_705_738

Fast to calculate, but too many to count.

It has a loop that has the potential to take a very long time or be infinite. Therefore it doesn’t really matter how simple, short or functional it is, it’s likely to have something wrong or suboptimal in the code that’s causing it either to run for a very long time, or forever :slight_smile:

You’re also posting only one function out of many that are in this exercise - so it’s possible something else in the exercise is wrong.

When you say it runs fine for you, are you running all the tests for the exercise in VS Code? Could you show your output from those local tests please?

Thanks for your feedback.
Actually my code was just plain wrong but it’s odd that I didn’t get the usual correction page open up rather than have it crash?
Anyway, thanks for your concern and help! :slightly_smiling_face:

Hi, guys! I’d like to know how can i do the last task? I’m stuck with it :(

If you share your code and error message, someone may be able to help. Without any details … you do it by writing code which implements the requirements.

def exchangeable_value(budget, exchange_rate, spread, denomination :float):
“”"

:param budget: float - the amount of your money you are planning to exchange.
:param exchange_rate: float - the unit value of the foreign currency.
:param spread: int - percentage that is taken as an exchange fee.
:param denomination: int - the value of a single bill.
:return: int - maximum value you can get.
"""

I’m trying to get a logic to atribute for this task

I have no problem with the error mesage, but i’m trying to find a programing logic to relate with the last task