Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Q8
- def neg1Pos0Zero0(x):
- """Retorna:
- 1 para numeros negativos
- 0 para numeros nao-negativos (inclusive 0)
- """
- return (x%(2*(x**2 + 1)))//(x**2 + 1)
- def neg0Pos1Zero1(x):
- """Retorna:
- 1 para numeros nao-negativos (inclusive 0)
- 0 para numeros negativos
- """
- return -(neg1Pos0Zero0(x) - 1)
- def menor(x,y):
- """Retorna o menor entre dois numeros. Se forem iguais, retorna o numero"""
- return x*neg1Pos0Zero0(x-y) + y*neg0Pos1Zero1(x-y)
- def menor3(x,y,z):
- """Retorna o menor entre tres numeros. Se forem iguais, retorna o numero"""
- return menor(z,menor(x,y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement