Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
6-liner: thanks to Heron’s formula solution in Clear category for Simple Areas by Stensen
from math import prod, sqrt, pi
def simple_areas(*args):
if len(args) == 1: return (args[0] / 2) ** 2 * pi
if len(args) == 2: return prod(args)
s, (a, b, c) = sum(args)/2, args
return sqrt(s*(s-a)*(s-b)*(s-c))
Oct. 25, 2020
Comments: