Fix: Loosen convex hull test constraints

This commit is contained in:
2025-11-07 13:51:45 -08:00
parent d8d7e6c95f
commit cc56811118

View File

@@ -3,7 +3,7 @@ export default {
prompt: `// Write an async JavaScript function 'findConvexHull' that finds the convex hull of a set of 2D points using the Monotone Chain algorithm.
// - The function must accept an array of points, e.g., [{x: 0, y: 3}, {x: 1, y: 1}, ...].
// - You MUST use a dynamic import() to load the 'lodash' library from a CDN for sorting and uniqueness operations.
// - The function should return an array of points representing the convex hull, ordered clockwise.`,
// - The function should return an array of points representing the convex hull.`,
runTest: async (findConvexHull) => {
const assert = {
deepStrictEqual: (a, e, m) => { if (JSON.stringify(a) !== JSON.stringify(e)) throw new Error(m) },
@@ -14,6 +14,7 @@ export default {
];
const expected = [{x: 0, y: 0}, {x: 3, y: 1}, {x: 4, y: 4}, {x: 0, y: 3}];
const hull = await findConvexHull(points);
assert.deepStrictEqual(hull, expected, "Test Failed: Convex hull does not match.");
const sortFn = (a, b) => a.x - b.x || a.y - b.y;
assert.deepStrictEqual(hull.sort(sortFn), expected.sort(sortFn), "Test Failed: Convex hull points do not match.");
}
};