def exact_div(p, d, allow_divzero=False):
 if ((not isinstance(p, (int, long))) or (not isinstance(d, (int, long)))):
  raise TypeError(('unsupported operand type(s): %r and %r' % (type(p).__name__, type(d).__name__)))
 if ((d == 0) and allow_divzero):
  n = 0
  if (p != (n * d)):
   raise ValueError('No solution could be found')
 else:
  (n, r) = divmod(p, d)
  if (r != 0):
   raise ValueError('No solution could be found')
 assert (p == (n * d))
 return n

def exact_div ( p , d , allow_divzero = False ) : if ( ( not isinstance ( p , ( int , long ) ) ) or ( not isinstance ( d , ( int , long ) ) ) ) : raise TypeError ( ( 'unsupported operand type(s): %r and %r' % ( type ( p ) . __name__ , type ( d ) . __name__ ) ) ) if ( ( d == 0 ) and allow_divzero ) : n = 0 if ( p != ( n * d ) ) : raise ValueError ( 'No solution could be found' ) else : ( n , r ) = divmod ( p , d ) if ( r != 0 ) : raise ValueError ( 'No solution could be found' ) assert ( p == ( n * d ) ) return n
find and return an integer n such that p == n * d if no such integer exists .