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)

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 :)

Physicist turned data scientist. Creator of http://datasciencetrivia.com a Q&A card game to learn key data science concepts by playing.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store