
import math
from fractions import Fraction
import sympy as sp
pi = sp.pi
sqrt = sp.sqrt
deg = math.pi / 180.0
def fmt(v):
f = float(v)
return str(int(round(f))) if abs(f - round(f)) < 1e-9 else f'{f:.2f}'
w, h, cut_w = 24, 16, 8
rect = w * h
removed = cut_w * h # two half-rectangles
answer = rect - removed
assert answer == (w - cut_w) * h
print('ANSWER=' + fmt(answer))
print('TRAP_RECT_AREA=' + fmt(rect))
print('TRAP_ONE_TRIANGLE=' + fmt(rect - cut_w * h / 2))
print('TRAP_SUM_OF_CUTS=' + fmt(cut_w * h))
Only each person's first answer, given before viewing the solution, is counted.
Discussion 0 comments
Log in to join the discussion.