Santa’s List: A Serious Computational Inquiry
Santa makes a list, checks it twice, and finds out who is naughty or nice. This appears to describe a straightforward batch-processing system with a seasonal deadline. But does it withstand a serious inquiry from a computational perspective?
At planetary scale, even a modest administrative procedure deserves scrutiny. We should determine whether the list can be processed more efficiently, whether the second check contributes anything, and whether the resulting judgments concern actual people or merely the successful operation of a database.
The requirements are brief. Their implementation will not be.
The complexity of Christmas
Let be the number of eligible people. Suppose making an entry costs , and checking it costs . A straightforward implementation requires:
If making and checking each cost one unit, this becomes operations. It is tempting to describe the procedure as and propose reducing it to .
Unfortunately:
Santa already has a linear-time algorithm. Computer science has declared the constant factor uninteresting; payroll has declined to agree.
The distinction matters because asymptotic notation does not make two unnecessary planetary scans free. It merely ensures that their expense is expressed in the same mathematical category as one planetary scan.
We have also assumed that a check has constant cost. If evaluating person requires examining behavioral reports, the accounting becomes:
Writing the names may be the easy part. Finding out what their owners have been doing introduces evidence, interpretation, and appeals. These are not ordinarily constant-time operations, despite what the administrative portal says.
Is it Naughty OR Nice xor Naughty XOR Nice
This is not Skate or Die, but some similarities are immediately obvious. Most listeners understand “naughty or nice” as exactly one:
That policy requires both completeness and exclusivity:
Two Boolean fields allow four states:
| Naughty | Nice | Interpretation |
|---|---|---|
| False | False | Neither / Neutral |
| False | True | Nice only |
| True | False | Naughty only |
| True | True | Both / Balanced? |
But we should distinguish neither from neutral. Neither might mean no relevant behavior, no available evidence, or an unprocessed record. Neutral might mean substantial evidence on both sides that balances under the chosen policy.
Santa should also not award moral equilibrium to somebody whose file failed to load or had two entries for both states.
One number tidies away the evidence
A bounded score seems simpler:
Alternatively:
These are different coordinate systems, not necessarily different moral theories. Their chief problem is that a single score conceals how it arose.
Someone with no recorded behavior and someone with a thousand acts of each kind might both score neutral. One has an empty history; the other has maintained an exhausting extracurricular schedule.
A signed net score makes the loss explicit:
Here, counts nice events and naughty events. Many histories produce the same difference. The database has compressed the evidence by making kindness and misconduct cancel, a facility neither their beneficiaries nor their victims necessarily requested.
The bounded scales introduce another question: what happens at the endpoints? Clamping a running score can discard history; recomputing a bounded score from a ledger can preserve it elsewhere. Santa must decide whether the thousand-and-first offence matters or whether the recipient has exhausted the system’s capacity for disappointment.
Two counters preserve balance and volume
A two-counter model gives us:
For equal-weight events:
Now we retain two useful quantities:
The difference determines which side predominates; the volume distinguishes quiet neutrality from vigorous cancellation.
Since both counters are unsigned, the absolute value of their sum is unnecessary:
Santa has finally found an operation he can remove without changing the result. It is regrettably not one of the checks.
Equal weighting remains a substantive policy. Returning a pencil and rescuing somebody each increment the same counter unless we introduce weights. That is not a reason to abandon the model, but it is an excellent place for the article to admit that arithmetic has begun making ethical decisions.
The increments must not be performed twice
One technical correction is essential: incrementing a counter is not idempotent. The ledger operation must ensure that each logical event contributes at most once.
For event identifier :
That requires deduplication and a consistent relationship between committing the event and updating—or deriving—the counters. Simply attaching an identifier does not make two increments safe.
This connects beautifully to the second check ("checking it twice"):
- Replay the ledger into fresh counters: independently recompute the totals.
- Replay it into the existing counters without deduplication: double the totals.
- Deliver every event twice with correct idempotency: preserve the totals, but not gain independent evidence.
Worse, a doubled ledger can preserve every ratio:
while doubling the volume:
A second check that examines only naughtyish versus niceish may therefore pass a corrupted aggregation. The verdicts agree; the activity totals are wrong. If duplication affects people unevenly, the volume rankings can change as well.
Hashing: finding the mistake faster
A hash table keyed by a stable person identifier can provide expected constant-time lookup under suitable hashing and load-management assumptions:
This is useful. Santa can retrieve a judgment quickly without searching through several billion unrelated judgments.
It does not follow that checking the whole population becomes constant-time:
Nor does a hash collision mean two people must receive the same verdict. A correctly implemented table resolves collisions by comparing keys. If Santa mistakes equal hashes for equal people, he has not discovered an optimization. He has discovered a way to distribute one child’s disciplinary record among strangers.
Hashing also offers an enticing second meaning: compute a digest of the list, then compare it with a trusted digest.
With an appropriate cryptographic hash and trusted reference, this provides strong evidence that the representation has not changed. Computing the digest from scratch still requires reading the representation.
More importantly, an unchanged false accusation remains false. Integrity protects the mistake from tampering; it does not apologize to its recipient.
What, precisely, has been checked?
At this point, “check” has performed several jobs without submitting a revised job description.
Santa might:
| Operation | What it establishes | What remains unresolved |
|---|---|---|
| Validate | The record satisfies a schema | Whether its claims are true |
| Authenticate | A source or user has established an identity | Whether that party is honest |
| Compare | Two records agree | Whether both are wrong |
| Verify integrity | Data matches a trusted reference | Whether the reference deserves trust |
| Analyse | A model produces a classification | Whether the model is appropriate |
| Audit | A prescribed process was followed | Whether the process is just |
A record can be valid, authenticated, unaltered, and entirely wrong. Its accusation can arrive over an encrypted connection, carry a digital signature, and pass every required field constraint. None of these accomplishments establishes that the biscuit was stolen.
An authenticated liar is still a liar. Authentication merely improves the accuracy of the return address.
Santa can also “check off” an entry after reviewing it. The second check might then confirm that every entry has a checkmark:
This is a claim about marks, not reviews. Establishing that the reviews happened requires trusting the marking process, inspecting its evidence, or commissioning another audit. The audit log has now become a second list, with its own need to be checked.
Administrative certainty is expanding faster than moral knowledge.
Checking twice: the reproducibility department
Let classify a fixed record using a deterministic procedure. Santa evaluates it twice:
Then:
The agreement is not surprising. It is what determinism means.
Repeating the computation can help detect some transient execution faults. It does not expose a systematic error in the procedure. If the classifier incorrectly treats “returned a lost wallet” as suspicious possession of somebody else’s property, both passes may condemn the same child with admirable consistency.
A second elf is not necessarily an independent check either. Two elves reading the same false report have doubled the staffing without doubling the evidence.
If each checker has error probability , independence would make the probability that both are wrong:
Without independence, the relevant expression is:
If both rely on the same defective evidence or rule, the second error may be almost assured once the first occurs. The confidence calculation improves only after Santa assumes away the failure mode he most needs to investigate.
Even two genuinely independent checks require a disagreement policy. A nice verdict and a naughty verdict do not average into a smaller present without an additional theory of justice.
Naughty, then nice
Perhaps the first pass checks for naughtiness, while the second checks for niceness.
Let:
There are four possible states:
| Naughty? | Nice? | Administrative consequence |
|---|---|---|
| No | No | Neither category applies |
| No | Yes | Present |
| Yes | No | Coal |
| Yes | Yes | Requirements meeting |
Nothing about these predicates initially establishes:
A person can be kind in one circumstance and unpleasant in another. If Santa defines nice as “not naughty,” the second classification is logically redundant. If he evaluates niceness independently, a single Boolean field is inadequate.
The first pass might instead search for evidence of wrongdoing, and the second for evidence of kindness. These searches can both succeed or both fail. Failure to find misconduct does not prove generosity; failure to find generosity does not establish misconduct.
Santa must therefore supply a policy: weights, thresholds, time windows, treatment of repentance, and a decision rule for missing evidence. The data model wants one bit. Human behavior has declined to fit.
Two lists, four problems
Suppose Santa maintains separate naughty and nice lists, and , covering an eligible population .
If the categories must be exclusive and exhaustive, two invariants are required:
The first prevents double classification. The second prevents omission.
Neither implies the other. Two empty lists are perfectly disjoint and wholly useless. Two lists containing everyone achieve complete coverage while turning every delivery into a dispute.
Transferring a rehabilitated child introduces a synchronization problem. Remove them from the naughty list first, and they temporarily belong to neither. Add them to the nice list first, and they temporarily belong to both. A suitable transaction can make the change atomic, provided the relevant storage system supports it and the operation actually uses it.
One authoritative record per person is simpler:
The two lists can then be derived views. This reduces contradictory storage without establishing that the verdict is correct. A unique constraint guarantees one record per key, not one key per human, and certainly not one justified judgment per childhood.
Santa has made disagreement harder to represent. Whether he has resolved it is a separate question.
The list changes while he checks it
Two complete passes require time. During that time, people continue behaving.
The checks now evaluate:
If the results disagree, the checker might be faulty—or the person might have changed. If the results agree, the person might still have changed twice between observations. Equal endpoints do not prove an uneventful interval.
Santa can freeze a snapshot:
Both passes now concern the same input. They also disregard everything that happened after . To make the audit reproducible, Santa has established a point after which being good no longer helps.
Checking each entry twice immediately after creating it improves locality and may avoid two later full-list scans. It does not necessarily reduce the number of per-entry operations:
for each person:
create entry
check entry
check entry again
It also changes the temporal arrangement. “Each entry checked twice” is not necessarily “the completed list checked twice,” and neither arrangement eliminates the gap between clearance and delivery.
A recipient can behave badly after the final check but before the present arrives. This is a time-of-check/time-of-use problem, now wearing mittens. Fixing it requires locking behavior, accepting a cutoff, or admitting that the verdict describes a past state rather than a permanent character.
Only the last two appear operationally defensible.
Distributed judgment
Santa could partition the work among elves. Under ideal balancing and independent constant-cost checks:
Total work remains linear. Elapsed time decreases by acquiring additional workers, computers, or employees whose seasonal enthusiasm has been mistaken for unlimited capacity.
Replication introduces a different concern. Two passes or two categories do not themselves invoke the CAP theorem. A distributed service encounters the relevant tradeoff when a network partition prevents its replicas from communicating.
During such a partition, Santa cannot guarantee both single-copy-consistent behavior and a response to every request at non-failing nodes. A disconnected workshop must sometimes wait for coordination or respond without a guarantee that its answer reflects the authoritative state.
The local copy says nice. Headquarters may have processed a later offence. Alternatively, headquarters still says naughty while the local workshop has received a valid appeal. Geography has become an input to the moral result.
Eventual consistency may reconcile the records afterward. This is less reassuring once the coal has been delivered. A converged database does not retrieve a Christmas morning.
Christmas as a stream
Instead of rebuilding the list annually, Santa could maintain classifications continuously.
Let be a behavioral event, and update a person’s state using:
If only records need reevaluation, an incremental audit may examine rather than , assuming no global policy change or hidden dependency invalidates the rest.
The work has not disappeared. Christmas has become a year-round surveillance and dispute-resolution service.
“Checking twice” now raises a new danger: processing an event twice. If the system increments a misconduct score on every delivery, one stolen biscuit becomes two.
An idempotent operation satisfies:
This handles repeated delivery of the same identified event. It does not automatically recognize two separately submitted reports describing the same incident. Deduplicating messages and deduplicating reality are different projects.
Reports also arrive late, out of order, or followed by retractions. An append-only log preserves what Santa was told; it does not guarantee that what he was told happened. Establishing the current judgment requires rules for corrections, appeals, and which events supersede others.
A batch can finish because it closes its input. A stream can remain current because it keeps accepting input. Santa would prefer both properties without accepting the consequences of either.
Faster answers to smaller questions
Sampling can estimate error rates under appropriate assumptions. It cannot establish that every person was checked. A Bloom filter can represent naughty-set membership compactly, but false positives may implicate people never inserted into that set. The storage savings are real; so are the recipients.
Quantum search offers a more glamorous misunderstanding. Under the appropriate oracle model, Grover’s algorithm can find a marked entry using roughly:
oracle queries.
Finding one naughty person is not classifying everyone. Preparing access to the data is not automatically free, and producing an explicit verdict for every person still requires linear output work. Quantum Christmas has located a suspect efficiently and left the actual assignment pending.
Under a model of arbitrary independent inputs, exact classification, and explicit output, Santa faces:
An unexamined input could be the one that changes the result. An unwritten verdict is not part of the completed list.
Sublinear improvements therefore require preprocessing, additional structure, compressed output, probabilistic guarantees, or a smaller question. These can all be legitimate. They should not be confused with doing the original job faster merely because the revised job retains its name.
Is This The Best Santa Can Do?
A Serious Proposal
Having established that checking is ambiguous, classification is political, and sorting does not improve anybody’s behavior, we should offer an implementation. Criticism is inexpensive partly because it is rarely required to support nine billion users.
Our proposal is approximately efficient. Its principal costs are linear or near-linear in the data processed, with smaller costs for individual updates and queries. These are, technically, polynomial bounds. We therefore cannot promise that the system is “not polynomial,” however reassuring that phrase might sound in a procurement meeting.
We can promise to avoid unnecessary quadratic work. Pairwise comparison of every child with every other child would require roughly:
comparisons.
It is unclear what these comparisons would establish. Most children have never met most other children, and Santa need not introduce them merely to determine which is worse.
Maintain the answer instead of rebuilding it
The authoritative input is an event ledger. Each accepted event has a unique identifier, a person identifier, a classification or contribution, provenance, and timestamps. Corrections and retractions must be represented explicitly. An accusation does not become permanently true because an append-only storage engine dislikes erasure.
The ledger feeds person records partitioned by a hash of person ID. Each record contains the counters, current classification, and version. We partition by identity rather than moral status so that repentance does not require moving the authoritative record between servers.
Each shard also maintains category indexes. Updating a person’s counters and changing their category membership must be one atomic local operation. Otherwise, the person may become nice in the record while remaining naughty in the index, an arrangement more familiar to bureaucracy than to generosity.
Event application must be idempotent:
The increment itself is not idempotent. Deduplication must ensure that the same logical event contributes once. Receiving the report twice does not establish that the biscuit was stolen twice.
With dense internal identifiers, bitmaps provide compact category membership. At nine billion people, one raw bitmap occupies approximately:
Four such bitmaps require about 4.5 GB before overhead. This is quite manageable. The larger expense is retaining the evidence, corrections, and explanations that make the bits defensible.
Santa can afford the list. Whether he can afford to justify it remains under review.
Make Christmas a snapshot, not a reconstruction
The initial construction still requires processing the population and its relevant evidence. We do not obtain nine billion justified records by declaring a pointer to them.
Once the records and indexes exist, however, “make the list” can mean creating a snapshot manifest that references their committed versions.
For shards:
This is work proportional to the number of participating shards, not necessarily the number of people. It requires a defined snapshot protocol: a collection of convenient local timestamps is not automatically one coherent global cutoff.
Individual record lookups can use expected constant-time local hash-table access, plus routing and communication. Category counts can come from maintained aggregates. Naughty and nice collections can be opened without first reconstructing their membership.
Enumerating those collections remains another matter. If their sizes are and , emitting their identities requires at least:
Under a complete two-category delivery policy:
The complete output is therefore linear. A manifest makes the list available cheaply; it does not make every entry appear on paper cheaply. Santa has replaced rewriting the list with referring to the list, a distinction sufficiently important that it should survive the executive summary.
The Missing Ingredient(s)
The first check should not be a vague assertion that everything looks festive. It should name its invariants.
For example, category membership must agree with the counters:
with corresponding rules for naughtyish, balanced, and unobserved records.
The categories should be pairwise disjoint and collectively cover the eligible population:
Transactions, uniqueness constraints, and commit-time validation can preserve many of these properties incrementally. Stored category counts provide additional checks, although correct totals do not prove correct membership. Swapping one nice child with one naughty child leaves the arithmetic satisfied and two households less so.
Authenticated hash trees can help detect changes relative to trusted commitments. Comparing roots is inexpensive once those roots have been maintained; updating an affected path typically requires logarithmic hashing work in a balanced tree.
These mechanisms establish structural consistency or integrity. They do not establish the truth of an accusation, the adequacy of an investigation, or the fairness of treating all events equally. A signed, well-formed, exactly-once injustice remains available for immediate retrieval.
Make the second check genuinely different
The first check operates when an event is committed. It validates the event, prevents duplicate application, and maintains the record and indexes.
The second check independently reconstructs the affected totals from committed ledger data and compares them with the materialized state.
If people changed and their relevant ledger histories contain events, a straightforward reconciliation takes approximately:
This can be sublinear in the population when the affected workload is small. One changed person with an enormous history can nevertheless be expensive; the letter is not a waiver for the evidence behind it.
The reconciliation must use the same cutoff and policy version as the state it checks. Otherwise, disagreement may simply mean that one pass knows about a later offence or an earlier appeal.
It must also reconstruct into fresh totals rather than apply the events again to existing counters. Doubling both counters preserves the ratio:
while doubling the recorded volume:
A check that compares only the final naughtyish or niceish verdict can therefore approve corrupted totals. Santa has counted twice and verified the result using the statistic least inclined to complain.
Targeted reconciliation does not independently certify untouched records against arbitrary corruption. Stronger assurances require additional integrity mechanisms and periodic broader audits. A full ledger replay remains proportional to the evidence examined:
We should budget for that work rather than describe its absence as an optimization.
Final judgment
Sorting can improve lookup. Hashing can improve lookup further. Arrays can make traversal cheaper. Transactions can preserve storage invariants, snapshots can make repeated checks comparable, and independent evidence can make a second review genuinely informative.
None of these establishes that a valid record is true, that an unchanged judgment is justified, or that two agreeing reviewers know more than the source they both consulted.
The cheapest classification policy is:
The rule has constant-size representation. Producing the full list and delivering the presents remain expensive. Santa has not optimized the investigation; he has abolished it. This may constitute moral progress, but it should be recorded as a policy change rather than a benchmark result.
“Checks it twice” counts an activity while suggesting an assurance. To earn that assurance, Santa must specify what the checks establish, why their evidence deserves trust, how disagreement is resolved, and which version of the world the verdict concerns.
Until then, the most defensible conclusion is that the list has undergone two operations described as checking. Both operations may have completed successfully.
Is O(N) Sufficient and Necessary?
The proposal offers sublinear Christmas-time access, incremental maintenance, and targeted reconciliation.
This is an excellent phrase. It is also substantially less than a sublinear algorithm for making and checking (twice) an entirely new planetary list.
The system obtains its performance through:
The work has been distributed across the year and across machines. Some unnecessary work has been removed. Some questions have been narrowed. The cost of explicit complete output has not been abolished, and correctness has not become a property of whichever operation finishes first.
We are therefore constructivists in favor of a season. We propose actual records, actual update rules, an actual cutoff, and a procedure that can finish while there is still a Christmas to administer. We do not require Santa to prove a permanent theorem about every person’s character before allowing fulfillment to begin.
The final snapshot represents judgments under a stated policy, based on evidence accepted by a stated deadline. Later information can produce corrections, not retroactively make the snapshot omniscient. Uncertainty should remain visible, and borderline cases should receive the benefit of a seasonal policy rather than the penalty of a database convenience.
The presents will still require linear work to deliver. That is not an algorithmic embarrassment. Doing something for everyone is ordinarily expensive because everyone is included.
Santa can make the administration efficient without making the generosity sublinear. We recommend preserving that particular inefficiency.
Acknowledgements
This post was written with the help of AI. The author takes responsibility for its contents, including any classifications that should have been checked a third time.
Photo by Vitaly Gariev on Unsplash
Top comments (2)
I had Gemini find a valid objection to my article and it came up with a pretty good one!
a doubled ledger keeping every ratio while doubling the volume is the sharpest bit. a second check that only looks at ratios passes corrupted totals without blinking.