Implement prototype(commands) and solve(commands), starting with an empty key set. Commands are [operation, key]. add/remove return a boolean indicating whether membership changed; contains returns a boolean; floor returns the greatest stored Number<=key or null. Return one result per command. Unknown operations throw RangeError.
[["add", 3], ["add", 3], ["floor", 4], ["remove", 9]] returns [true, false, 3, false]. Empty commands return [].
Prototype: an unsorted unique-key array. Final: a BST with correct deletion and floor search. Preserve commands, including on failure. Use actual booleans for boolean operations, not 0/1 substitutes.
All numeric inputs and finite arithmetic results in this lesson are safe-integer Numbers. Use null for documented absence, not undefined or a numeric sentinel. Return actual booleans where the contract requires them. Do not add validation requirements beyond the documented inputs.
Run with Node.js 20+ from this directory:
node main.mjs --stage prototype
node main.mjs --stage finalEdit exercise.mjs; keep main.mjs unchanged. Both stages begin as unfinished learner functions. The website uses the same test functions in a separate browser worker. Tests check deterministic examples, boundaries, documented validation, input preservation, and stage-specific cases. Passing tests does not prove the required time complexity.
Complete the starter code, then run the checks.
Results and errors will appear here.