Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Without if/else solution in Creative category for Compare Functions by martin_b
def checkio(f, g):
def c(f, *args, **kwargs):
try:
return f(*args, **kwargs)
except:
return None
def h(*args, **kwargs):
fr = c(f, *args, **kwargs)
gr = c(g, *args, **kwargs)
return {
(False, False): (None, 'both_error'),
(True, False): (fr, 'g_error'),
(False, True): (gr, 'f_error'),
(True, True): (fr, {True: 'same', False: 'different'}[fr == gr])
}[(fr != None, gr != None)]
return h
April 1, 2016
Comments: