ahmed-wez's picture
Candidate development release: 5000 verified tasks; evaluation withheld
6a48c9d verified
Raw History Blame Contribute Delete
4.01 kB
from common import register
D = 'geometry'
def add(n, c, t, s, e, **kw):
register(D, n, c, t, s, e, **kw)
add('coordinate_triangle_area', [['A triangle has vertices ({x},{y}), ({x2},{y2}), and ({x3},{y3}).', 'The three vertices are A=({x},{y}), B=({x2},{y2}), C=({x3},{y3}).', 'Consider the triangle through points ({x},{y}), ({x2},{y2}), ({x3},{y3}).']], ['What is its area in square units?', 'Find the exact triangle area.', 'Determine the area enclosed by the vertices.'], lambda r: dict(x=r.randint(1, 10), y=r.randint(1, 10), x2=r.randint(12, 25), y2=r.randint(1, 10), x3=r.randint(1, 10), y3=r.randint(12, 25)), [('cross_product', '(x2-x)*(y3-y)-(y2-y)*(x3-x)'), ('answer', 'abs(cross_product)/2')], level='medium', depth=3)
add('trapezoid_area', [['A trapezoid has parallel side lengths {a} and {b}, with perpendicular height {h}.', 'The two parallel sides of a trapezoid measure {a} and {b}; their perpendicular separation is {h}.', 'Use a trapezoid whose bases are {a} and {b} and whose height is {h}.']], ['What is its area?', 'Find the area in square units.', 'Determine the trapezoid area exactly.'], lambda r: dict(a=r.randint(5, 35), b=r.randint(38, 70), h=r.randint(3, 35)), [('mean_base', '(a+b)/2'), ('answer', 'mean_base*h')], level='easy')
add('similar_triangles_area', [['Two triangles are similar; corresponding side lengths are {a} on the smaller and {b} on the larger.', 'Similar triangles have a smaller-to-larger corresponding side ratio of {a} to {b}.', 'A side of length {a} on a smaller triangle corresponds to a side of length {b} on a similar larger triangle.'], ['The smaller triangle has area {s}.', 'Use {s} square units as the smaller area.', 'The area of the smaller figure is {s} square units.']], ['What is the larger triangle area?', 'Find the area of the larger triangle.', 'Determine the larger area in square units.'], lambda r: dict(a=r.randint(2, 15), b=r.randint(18, 40), s=r.randint(10, 150)), [('area_factor', 'b*b/(a*a)'), ('answer', 's*area_factor')], level='medium', depth=3)
add('right_triangle_altitude', [['A right triangle has perpendicular leg lengths {a} and {b}.', 'The legs meeting at the right angle measure {a} and {b}.', 'Use a right triangle with legs {a} and {b}.']], ['What is the square of the altitude to the hypotenuse?', 'Find the altitude to the hypotenuse squared.', 'Determine the squared perpendicular distance from the right-angle vertex to the hypotenuse.'], lambda r: dict(a=r.randint(3, 45), b=r.randint(3, 45)), [('hypotenuse_squared', 'a*a+b*b'), ('answer', 'a*a*b*b/hypotenuse_squared')], level='hard', depth=3)
def right(r):
m = r.randint(3, 15)
n = r.randint(1, m - 1)
s = r.randint(1, 6)
return dict(a=s * (m * m - n * n), b=s * 2 * m * n, c=s * (m * m + n * n))
add('right_triangle_inradius', [['A right triangle has leg lengths {a} and {b} and hypotenuse {c}.', 'The side lengths of a right triangle are {a}, {b}, {c}, with {c} the hypotenuse.', 'Use a right triangle whose perpendicular legs measure {a} and {b} and whose longest side measures {c}.']], ['What is the radius of its inscribed circle?', 'Find the inradius.', 'Determine the radius of the circle tangent to all three sides.'], right, [('semiperimeter', '(a+b+c)/2'), ('area', 'a*b/2'), ('answer', 'area/semiperimeter')], level='hard', depth=3, concepts=3)
add('parallelogram_diagonal', [['A parallelogram has adjacent side lengths {a} and {b}; one diagonal has length {d}.', 'In a parallelogram, the sides meeting at a vertex measure {a} and {b}, and a diagonal measures {d}.', 'Use a parallelogram with neighboring sides {a}, {b} and one diagonal of length {d}.']], ['What is the square of the other diagonal length?', 'Find the other diagonal length squared.', 'Determine the squared length of the remaining diagonal.'], lambda r: (lambda a, b: dict(a=a, b=b, d=r.randint(abs(a - b) + 1, a + b - 1)))(r.randint(8, 35), r.randint(8, 35)), [('diagonal_square_sum', '2*(a*a+b*b)'), ('answer', 'diagonal_square_sum-d*d')], level='hard', depth=3)