Skip to content

Instantly share code, notes, and snippets.

@limpido
Created November 21, 2023 01:39
Show Gist options
  • Save limpido/06e04d673b2c1f158c90152e3cbd87ee to your computer and use it in GitHub Desktop.
Save limpido/06e04d673b2c1f158c90152e3cbd87ee to your computer and use it in GitHub Desktop.
"""
f(1) = -1
f(-1) = 1
"""
def f1(x):
return -x
def f2(x):
return 1 if len(str(x)) > 1 else -1
def f3(x):
arr = [None, -1, 1]
return arr[x]
def f4(x):
s = set([1, -1])
s.remove(x)
return list(s)[0]
def f5(x):
return (x ^ -1) + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment