Malcolm Low | Practical AI, Computing & Quantum Research

Singapore-based practical guides, tutorials and experiments in AI, computing, modelling, simulation, optimisation and quantum computing, with research notes and hands-on workflows.

, , , ,

Kaggle Santa 2026: A Gentle Introduction to the Elf Calculator

A beginner’s guide to the Kaggle Santa 2026 Elf Calculator: how instructions and registers work, nine levels of shorter arithmetic programs from 1 + 1 upward, and a complete example of the submission CSV.

·

Written by

KAGGLE SANTA 2026
A gentle introduction to the Elf Calculator: instructions, registers, shorter programs and the submission file.

Every December, Kaggle runs a Santa-themed optimisation competition. The 2026 edition, the Elf Calculator, is a puzzle in arithmetic program synthesis: given some starting numbers, write the shortest possible program of additions, subtractions, multiplications and divisions that produces a list of target numbers. The idea fits on one line, yet finding truly short programs turns into a rich search and optimisation problem.

This article starts from the simplest possible programs, 1 + 1 and 1 + 1 + 1, explains the machine the programs run on, builds up the main tricks for shortening programs one level at a time, and finishes with a complete worked example of the CSV file that gets submitted to Kaggle.


1  ·  The Challenge at a Glance
ItemDetail
GoalFor each puzzle, write a program that produces every target value at least once
Operations+ - * / on whole numbers
Puzzles1,000 scored puzzles, plus a set of practice puzzles
Data filespuzzles.csv, practice_puzzles.csv, sample_submission.csv
ScoreTotal number of instructions across all 1,000 programs (lower is better)
SubmissionA CSV with columns id,program, one row per puzzle

Because the score is a plain sum, every instruction saved on any puzzle improves the score by exactly one. A competitor who trims one instruction from each of the 1,000 puzzles gains 1,000 points.

2  ·  The Architecture: Instructions and Registers

The programs run on a tiny abstract machine. It has two parts: a bank of registers that hold numbers, and a list of instructions that combine them.

Registers

A register is a numbered storage slot. Each puzzle supplies a register count, which is 48 for the competition data, so the registers are r0 to r47. The starting values are loaded into registers before the program runs, and every other register starts empty. Here is the register file at the start of a puzzle whose only start value is 1:

r0
1
r1
empty
r2
empty
r3
empty
r4
empty
…
r47
empty
Instructions

Every instruction is a list of four items: [op, source_i, source_j, destination]. The operator is one of the four arithmetic signs and the other three items are register numbers, not values. The instruction reads the two source registers, applies the operator and writes the result into the destination register.

[
‘+’
op
1
source i
2
source j
3
destination
]
reads r1 and r2  →  computes r1 + r2  →  writes the result into r3

Each instruction takes exactly two inputs, so it is a lot like a single line of assembly code. The same register may appear in both source positions, which is how a value is doubled (['+', 1, 1, 2]) or squared (['*', 1, 1, 2]).

The rules
  • Read before write. Both sources are read before the destination is overwritten, so ['+', 0, 0, 0] safely doubles r0 in place.
  • No empty reads. A register can only be used as a source once it holds a value.
  • Positive integers only. Every result must be a whole number greater than zero and no larger than the puzzle’s value_limit. Subtraction must not go to zero or below.
  • Exact division. Division is only allowed when it leaves no remainder.
  • Targets appear once. A target only has to show up in some register at some point; it may be overwritten later.
  • Size limits. At most 4,096 instructions and 128 KiB of text per program.
Watching a program run

The trace below follows the five-instruction program for the target 100 (Level 7 in the next section). Bold marks the register written at each step; a dot marks an empty register.

StepInstructionr0r1r2r3r4r5
start1·····
1['+', 0, 0, 1]12····
2['+', 1, 0, 2]123···
3['+', 1, 2, 3]1235··
4['*', 3, 1, 4]123510·
5['*', 4, 4, 5]123510100
Registers are a limited resource. With 48 of them, a program for a long target list has to overwrite values it no longer needs, which is exactly what the read-before-write rule makes safe.
3  ·  Starting Simple: Nine Levels

Each level below shows the puzzle, the obvious program, a shorter one and the trick that makes the difference. Programs appear twice: in a readable form with values filled in, and in the official four-item form that goes into the submission file. Every program here has been run through a checker, and a brute-force search confirms that each shortened program is the shortest possible.

Level 1 · 1 + 1

Start: [1]   Targets: [2]

The smallest possible puzzle. Register r0 holds the start value 1 and the target is 2. One instruction adds r0 to itself and writes the answer into the empty register r1.

1 instruction  Trick: One instruction, two inputs, one output.

Readable form
r1 = r0 + r0   →  1 + 1 = 2
Official form [op, source_i, source_j, destination]
['+', 0, 0, 1]
Level 2 · 1 + 1 + 1

Start: [1]   Targets: [3]

On paper 1 + 1 + 1 looks like one expression, but every instruction takes exactly two inputs. The expression therefore costs two instructions: first 1 + 1, then that result + 1.

2 instructions  Trick: An expression with k operands costs k − 1 instructions.

Readable form
r1 = r0 + r0   →  1 + 1 = 2
r2 = r1 + r0   →  2 + 1 = 3
Official form [op, source_i, source_j, destination]
['+', 0, 0, 1]
['+', 1, 0, 2]
Level 3 · target 4

Start: [1]   Targets: [4]

Writing 4 as 1 + 1 + 1 + 1 costs three instructions. Adding the 2 to itself costs two.

Naive: 1 + 1 + 1 + 1 = 3 instructions.  Shortened: 2.  Trick: Doubling: add a register to itself.

Readable form
r1 = r0 + r0   →  1 + 1 = 2
r2 = r1 + r1   →  2 + 2 = 4
Official form [op, source_i, source_j, destination]
['+', 0, 0, 1]
['+', 1, 1, 2]
Level 4 · target 8

Start: [1]   Targets: [8]

Adding 1 seven times costs seven instructions. Doubling three times (2, 4, 8) costs three.

Naive: 1 + 1 + … + 1 (eight ones) = 7 instructions.  Shortened: 3.  Trick: Repeated doubling reaches 2k in k steps.

Readable form
r1 = r0 + r0   →  1 + 1 = 2
r2 = r1 + r1   →  2 + 2 = 4
r3 = r2 + r2   →  4 + 4 = 8
Official form [op, source_i, source_j, destination]
['+', 0, 0, 1]
['+', 1, 1, 2]
['+', 2, 2, 3]
Level 5 · target 16

Start: [1]   Targets: [16]

Doubling needs four steps (2, 4, 8, 16). Multiplying 4 by itself skips a step.

Naive: 2, 4, 8, 16 by doubling = 4 instructions.  Shortened: 3.  Trick: Squaring: multiply a register by itself.

Readable form
r1 = r0 + r0   →  1 + 1 = 2
r2 = r1 + r1   →  2 + 2 = 4
r3 = r2 × r2   →  4 × 4 = 16
Official form [op, source_i, source_j, destination]
['+', 0, 0, 1]
['+', 1, 1, 2]
['*', 2, 2, 3]
Level 6 · targets [4, 5]

Start: [1]   Targets: [4, 5]

With two targets, building each one from scratch costs 2 + 3 = 5 instructions. Once 4 exists, 5 is just 4 + 1.

Naive: 4 from scratch, then 5 from scratch = 5 instructions.  Shortened: 3.  Trick: Reuse: build the next target from an earlier one.

Readable form
r1 = r0 + r0   →  1 + 1 = 2
r2 = r1 + r1   →  2 + 2 = 4
r3 = r2 + r0   →  4 + 1 = 5
Official form [op, source_i, source_j, destination]
['+', 0, 0, 1]
['+', 1, 1, 2]
['+', 2, 0, 3]
Level 7 · target 100

Start: [1]   Targets: [100]

The binary method doubles six times to reach 64, then adds 32 and 4: eight instructions. Factoring 100 = 10 × 10 and 10 = 5 × 2 needs only five.

Naive: 1 → 2 → 4 → … → 64, then 64 + 32 + 4 = 8 instructions.  Shortened: 5.  Trick: Factoring: multiply small factors.

Readable form
r1 = r0 + r0   →  1 + 1 = 2
r2 = r1 + r0   →  2 + 1 = 3
r3 = r1 + r2   →  2 + 3 = 5
r4 = r3 × r1   →  5 × 2 = 10
r5 = r4 × r4   →  10 × 10 = 100
Official form [op, source_i, source_j, destination]
['+', 0, 0, 1]
['+', 1, 0, 2]
['+', 1, 2, 3]
['*', 3, 1, 4]
['*', 4, 4, 5]
Level 8 · start {3}, target 30

Start: [3]   Targets: [30]

Doubling gives 6, 12, 24, then 24 + 6 = 30 in four instructions. Going past the target to 36 = 6 × 6 and subtracting 6 needs three.

Naive: 6, 12, 24, then 24 + 6 = 4 instructions.  Shortened: 3.  Trick: Overshoot and subtract.

Readable form
r1 = r0 + r0   →  3 + 3 = 6
r2 = r1 × r1   →  6 × 6 = 36
r3 = r2 − r1   →  36 − 6 = 30
Official form [op, source_i, source_j, destination]
['+', 0, 0, 1]
['*', 1, 1, 2]
['-', 2, 1, 3]
Level 9 · start {2}, targets [16, 17, 34]

Start: [2]   Targets: [16, 17, 34]

Built separately, 16 costs 2 instructions, 17 costs 4 and 34 costs 4: ten in total. Dividing 2 by itself gives a 1 to work with, and each target then grows from the previous one: 16, then 16 + 1 = 17, then 17 + 17 = 34.

Naive: each target built from scratch = 10 instructions.  Shortened: 5.  Trick: Anchor reuse, plus division to make a 1.

Readable form
r1 = r0 × r0   →  2 × 2 = 4
r2 = r0 ÷ r0   →  2 ÷ 2 = 1
r3 = r1 × r1   →  4 × 4 = 16
r4 = r3 + r2   →  16 + 1 = 17
r5 = r4 + r4   →  17 + 17 = 34
Official form [op, source_i, source_j, destination]
['*', 0, 0, 1]
['/', 0, 0, 2]
['*', 1, 1, 3]
['+', 3, 2, 4]
['+', 4, 4, 5]
4  ·  The Tricks in One Table
TrickIdeaExample
ReuseBuild the next value from one already in a register4 then 4 + 1 = 5
DoublingAdd a register to itself2, 4, 8
SquaringMultiply a register by itself4 × 4 = 16
FactoringWrite the target as a product of small factors100 = (2 + 3) × 2 squared
Overshoot and subtractJump past the target with a big step, then step back36 − 6 = 30
Anchor reuseGrow each target from the previous target16 → 17 → 34
Make a 1Divide a register by itself for a free small constant2 ÷ 2 = 1
5  ·  Submitting to Kaggle: A Complete Example

A submission is a single CSV file with one row per puzzle. Kaggle runs every program, rejects the file if any program breaks a rule, and otherwise reports the total instruction count.

Step 1 · The puzzles

For a complete example, suppose the puzzle file contained just three puzzles, taken from Levels 7, 8 and 9:

idStart valuesTargetsBest program
0[1][100]5 instructions
1[3][30]3 instructions
2[2][16, 17, 34]5 instructions
Step 2 · Each program as a list

Each program becomes a list of four-item instructions:

id 0:  [["+", 0, 0, 1], ["+", 1, 0, 2], ["+", 1, 2, 3], ["*", 3, 1, 4], ["*", 4, 4, 5]]
id 1:  [["+", 0, 0, 1], ["*", 1, 1, 2], ["-", 2, 1, 3]]
id 2:  [["*", 0, 0, 1], ["/", 0, 0, 2], ["*", 1, 1, 3], ["+", 3, 2, 4], ["+", 4, 4, 5]]
Step 3 · The file Kaggle receives

This is the complete submission.csv for the three puzzles, exactly as it sits on disk:

id,program
0,"[[""+"",0,0,1],[""+"",1,0,2],[""+"",1,2,3],[""*"",3,1,4],[""*"",4,4,5]]"
1,"[[""+"",0,0,1],[""*"",1,1,2],[""-"",2,1,3]]"
2,"[[""*"",0,0,1],[""/"",0,0,2],[""*"",1,1,3],[""+"",3,2,4],[""+"",4,4,5]]"

Two details stand out. The program cell contains commas, so the CSV writer wraps it in double quotes, and the quotes inside the cell are escaped by doubling them, so "+" becomes ""+"". Writing the file with Python’s csv module takes care of both automatically.

This tiny file scores 5 + 3 + 5 = 13. A real submission has 1,000 rows; a published baseline file is about 21 MB.

Step 4 · Generating the file
import csv, json

programs = {
    0: [["+",0,0,1], ["+",1,0,2], ["+",1,2,3], ["*",3,1,4], ["*",4,4,5]],  # 100 from {1}
    1: [["+",0,0,1], ["*",1,1,2], ["-",2,1,3]],                           # 30 from {3}
    2: [["*",0,0,1], ["/",0,0,2], ["*",1,1,3], ["+",3,2,4], ["+",4,4,5]],  # 16, 17, 34 from {2}
}

with open("submission.csv", "w", newline="") as f:
    w = csv.writer(f)                      # handles the quoting for you
    w.writerow(["id", "program"])
    for pid, prog in sorted(programs.items()):
        cell = json.dumps(prog, separators=(",", ":"))
        assert len(prog) <= 4096 and len(cell.encode()) <= 128 * 1024
        w.writerow([pid, cell])
Step 5 · Checking before uploading

One invalid program typically fails the whole submission, so it pays to run every program through a local checker that applies the rules from Section 2:

def check(start, targets, prog, value_limit, n_regs=48):
    reg = [None] * n_regs
    reg[:len(start)] = start               # assumption: start values fill r0, r1, ...
    seen = set(start)
    for op, i, j, d in prog:
        a, b = reg[i], reg[j]               # read both sources first
        if a is None or b is None:
            raise ValueError("read from an empty register")
        if op == "+": v = a + b
        elif op == "-": v = a - b
        elif op == "*": v = a * b
        elif op == "/":
            if a % b: raise ValueError("inexact division")
            v = a // b
        if not 0 < v <= value_limit:
            raise ValueError(f"value {v} out of range")
        reg[d] = v                          # then write the destination
        seen.add(v)
    missing = set(targets) - seen
    if missing:
        raise ValueError(f"targets never produced: {missing}")
    return len(prog)                        # this puzzle's contribution to the score
Step 6 · Uploading

The file can be uploaded on the competition page under Submit Prediction, submitted from a Kaggle notebook by writing it to /kaggle/working/, or sent with the Kaggle command-line tool:

pip install kaggle                       # API token goes in ~/.kaggle/kaggle.json
kaggle competitions download -c santa-2026
kaggle competitions submit -c santa-2026 -f submission.csv -m "factoring + anchor reuse"
kaggle competitions submissions -c santa-2026
Check against the official sample. The column names, the instruction form and the limits above are taken from the competition rules as quoted in public solver repositories. The exact text encoding of the program cell (shown here as a compact JSON list), the register that holds each start value (shown here as r0, r1, …) and the competition slug used in the commands are illustrative. Compare them with the first row of sample_submission.csv and the Data page before submitting.
6  ·  From Toy Examples to Real Solvers

Hand-crafting 1,000 programs is not practical, so competitors write solvers. A typical progression:

  1. Binary baseline. Make a 1, double repeatedly and add the needed powers of two. Always valid, rarely short, and a useful safety net for every puzzle.
  2. Factoring and overshoot. Try products of small numbers and nearby larger values that can be stepped back from, keeping whichever is shortest.
  3. Anchor reuse. Sort the targets and build each one from values already in registers, so a long target list costs little more than its first element.
  4. Exact search on small cases. Iterative deepening proves the true minimum for short programs and catches clever constructions the heuristics miss.
  5. Register allocation. With only 48 registers, decide which values to keep and which to overwrite, much like a compiler back end.

The brute-force search used to verify the levels in this article is only a few lines long:

from itertools import combinations_with_replacement as cwr

def shortest(start, targets, limit=10**6, maxdepth=6):
    """Iterative deepening: the fewest instructions that produce every target."""
    targets = set(targets)
    def ops(a, b):
        yield a + b; yield a * b; yield abs(a - b)
        if a % b == 0: yield a // b
        if b % a == 0: yield b // a
    def dfs(vals, d):
        if targets <= vals: return 0
        if d == 0: return None
        for a, b in cwr(sorted(vals), 2):
            for v in ops(a, b):
                if 0 < v <= limit and v not in vals:
                    r = dfs(vals | {v}, d - 1)
                    if r is not None: return r + 1
        return None
    for d in range(maxdepth + 1):
        if dfs(frozenset(start), d) is not None:
            return d

print(shortest({1}, [100]), shortest({3}, [30]), shortest({2}, [16, 17, 34]))   # 5 3 5

It explodes quickly beyond six or seven instructions, which is exactly why the real competition rewards smarter search: beam search, dynamic programming over addition chains, and caching of good sub-programs.

7  ·  Sources

Kaggle Santa 2026  ·  Python 3.10+

✦ This article was generated with the assistance of Claude by Anthropic ✦

Comments

Leave a Reply