Advertisement
SonGuhun

Min

Mar 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. #Q8
  2. def neg1Pos0Zero0(x):
  3.     """Retorna:
  4.        1 para numeros negativos
  5.        0 para numeros nao-negativos (inclusive 0)
  6.    """
  7.     return (x%(2*(x**2 + 1)))//(x**2 + 1)
  8.  
  9. def neg0Pos1Zero1(x):
  10.     """Retorna:
  11.        1 para numeros nao-negativos (inclusive 0)
  12.        0 para numeros negativos
  13.    """
  14.     return -(neg1Pos0Zero0(x) - 1)
  15.  
  16. def menor(x,y):
  17.     """Retorna o menor entre dois numeros. Se forem iguais, retorna o numero"""
  18.     return x*neg1Pos0Zero0(x-y) + y*neg0Pos1Zero1(x-y)
  19.  
  20. def menor3(x,y,z):
  21.     """Retorna o menor entre tres numeros. Se forem iguais, retorna o numero"""
  22.     return menor(z,menor(x,y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement