Start by clarifying the function signature and config schema, then implement a single calculator that dispatches on the destination's pricing model. Walk through each model with concrete examples, and finish by enumerating edge cases and how you'd test them, emphasizing correctness and maintainability.
Pro tip: Treat the config as a data-driven strategy map: each destination maps to a pricing function, so adding a new model doesn't require changing the core calculator. Also, explicitly state your assumptions about rounding and floating-point handling (e.g., work in cents or use a rounding helper) to show production awareness.
Define the function signature (e.g., calculateShipping(destination, quantity, config)) and show the config structure for each pricing model. Confirm assumptions about units, currency, and whether config is passed in or global.
Write a helper for each model: flat per-unit, tiered per-unit, and base fee + tiered beyond N. Use a dispatch mechanism (e.g., switch on config.type) to select the correct helper.
Trace through a sample quantity for each model to verify the math, including exact tier boundaries. Explain how tiered pricing works (e.g., first 10 units at $2, next 10 at $1.50).
List the required edge cases: quantity 0, exact tier boundaries, unknown destinations, negative inputs, and floating-point precision. Describe expected behavior and how you'd test each (e.g., unit tests with assertions).
Mention how you'd handle floating-point issues (e.g., integer cents, rounding), validation strategy, and how the design supports adding new pricing models without modifying existing code.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.