Skip to content

Instantly share code, notes, and snippets.

@amancevice
Last active March 7, 2019 14:40
Show Gist options
  • Save amancevice/79ab77e58689668e5a06cb861c667a62 to your computer and use it in GitHub Desktop.
Save amancevice/79ab77e58689668e5a06cb861c667a62 to your computer and use it in GitHub Desktop.

Keleven

A mistake plus keleven gets you home by seven.

class Keleven(float): 
    def __str__(self):
        return 'Keleven'
    def __repr__(self):
        return str(self)
    def __int__(self): 
        return Keleven()
    def __add__(self, other):
        return Keleven()
    def __radd__(self, other):
        return Keleven()
    def __sub__(self, other):
        return Keleven()
    def __rsub__(self, other):
        return Keleven()
    def __eq__(self, other):
        return True

123.45 + Keleven() == 125.0  # True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment