How many times can you spend money on nothing?
The other day I was taking a shower and a thought came to me: How many times can I exchange a dollar to Colones
(Costa Rican currency) then back to dollars and then to colones and so on until I have no money left?
I got out the shower and wrote this simple python script, turns out the answer is 111 (well at that moment because it depends of the exchange rate).
I’ll leave a repl.it so you can play a bit with it.
Little doc of the function always is nice.
spend_money_on_nothing(initial_amount = 1, buy_price = 570, sell_price = 582, threshold = 0.1)
initial_amount: integer, float, default 1
Initial amount in dollarsbuy_price: integer, float, default 570
Cost of buying a dollar at your chosen currencysell_price: integer, float, default 582
Cost of selling a dollar at your chosen currencythreshold: float, default 0.1
Stop condition, we will never get to 0. So it is necessary to have a stop condition.
This solution may not be the most efficient or glamorous so I am curious to see if some of you come up with a more clever way to solve this shower problem.
If you want to receive more stuff like this you can join to my new newsletter :)