Skip to content

Instantly share code, notes, and snippets.

@rileypeterson
Created February 21, 2020 07:54
Show Gist options
  • Save rileypeterson/57a72d3d27928b53fd54f8309fcd2d1b to your computer and use it in GitHub Desktop.
Save rileypeterson/57a72d3d27928b53fd54f8309fcd2d1b to your computer and use it in GitHub Desktop.
Code snippets I think are cool, but frowned upon or difficult to understand
import numpy as np
1/(0 or np.nan) # Avoid ZeroDivisionError
def get_odds(bet, profit):
_ = lambda x: x + min(-(x % 5), 5 - (x % 5), key=abs)
return round(_(100*(max(profit, bet) / min(bet, -profit, key=abs))))
assert get_odds(1, 1.25) == 125
assert get_odds(1, 1.32) == 130
assert get_odds(1, 0.8) == -125
assert get_odds(1, 0.91) == -110
assert get_odds(3.40, 5.91) == 175
assert get_odds(2.43, 1.28) == -190
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment