You will write three small functions about a flat lamina and about toppling.
The idea. A uniform lamina is made of rectangles. The weight of each rectangle is in proportion to its area, and acts at its middle. A rectangle is (x1, y1, x2, y2). A block topples when its tilt is more than the angle whose tangent is its width over its height.
Your tasks.
area, return the area of one rectangle.centre_of_gravity, return the pair (x, y) of the centre of gravity of a list of rectangles.topples, return True if a block of width w and height h tilted through tilt degrees topples.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…