FunctionRacerProblemsRace

Volume Over a Triangle

HardSciPyPython

A surface has height a * x * y + b * x**2 + c above the point (x, y). Return the volume under it over the triangle with corners (0, 0), (w, 0) and (w, s * w): all points with 0 <= x <= w and 0 <= y <= s * x.

Example 1

a 0.0
b 0.0
c 1.0
w 2.0
s 1.0
returns 2.0

A flat surface of height 1 over a triangle of area 2.

Example 2

a 0.0
b 0.0
c 3.0
w 4.0
s 0.5
returns 12.0

Height 3 over a triangle with base 4 and height 2.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More SciPy problems