Working with exact amounts

A small ledger exercise shows why the input format and arithmetic rules belong in the task brief.

Start with an explicit format

In our ledger example, amounts arrive as strings with exactly two decimal places. The brief says whether negatives are allowed, how duplicates behave and what the output should look like. These details remove several reasonable but incompatible interpretations of the task.

Choose arithmetic that fits the requirement

The reference implementation converts each amount to integer cents before adding it. A value such as 0.10 becomes 10 cents. The output is formatted back to a decimal string after the arithmetic is complete. This avoids introducing floating-point rounding into a task that requires exact cent values.

Test the boundaries, not only the happy path

The verifier checks invalid amounts, conflicting IDs, refunds, cancellation and very large values. It also tries every ordering of a three-entry input. A correct report should not change just because the rows arrived in a different order.

Keep the result in context

Passing these checks is evidence about this implementation and this test set. It is not a claim that the exercise covers every accounting requirement or every possible incorrect solution. The brief and verification code are public so the checks can be inspected.

Based on a Clorvin Labs internal demonstration. No client work or model performance is represented.