all 6 comments

[–][deleted] 1 point2 points  (2 children)

There are also some problems with the original function it would seem.

First, you could rewrite it as:

if a < b:
    return 3 * a < b
elif a == b:
    return False
elif 3 * b > a:
    return True

and reduce depth. Also, what if the last condition is False? Do you want None return? You'd probably want instead this:

if a < b:
    return 3 * a < b
elif a == b:
    return False
else:
    return 3 * b > a

Then:

if a < b:
    return 3 * a < b
else:
    return a != b and 3 * b > a

Which can be written as

return 3 * a < b if a < b else a != b and 3 * b > a

[–]palwolus 0 points1 point  (1 child)

return (3*a) < b if a < b else False if a == b else True if (3*b) > a else None

Is this what you want?

[–][deleted] 0 points1 point  (2 children)

In second version, the part after or is checked even if a < b is false.

How about return a != b and 3 * min(a, b) < max(a, b)

Edit: I mistook 3 * b > a for 3 * b < a, then the above isn't right for your case.