an esoteric programming language

Puzzle.

Every Puzzle program is the same two characters, repeated: f and a run of backticks. What the program does depends entirely on how many backticks there are — and on whether you can write a function that figures that out.

source → f``````…`` ← 2N backticks

How Puzzle works

The whole language is a trick of JavaScript grammar. A tagged template like f`hi` is just f called with a strings array. Chain more backticks on and each result gets called again as the next tag — f`````` calls f, then calls whatever it returned, then calls whatever that returned. A Puzzle program is nothing but that chain, stretched out to a specific length.

1 — Read the length

Count every backtick in the program and divide by two. That gives a single non‑negative integer, N — the number of tag calls in the chain, including the very first call to f itself.

backticks ÷ 2 = N

2 — Decode the bytes

N is not just a length. Treat N itself as a base‑256 number and expand it back into its bytes, most significant byte first. Those bytes, read as UTF‑8, are the source code of a tinylisp program.

bytes(N) → UTF‑8 → tinylisp source

3 — Run it

Execute the decoded text as tinylisp. tinylisp is the host language for Puzzle — the same interpreter backs this page's runTinylisp and runFromChainLength helpers below, so you don't need to write a Lisp from scratch to solve this.

What you do need to write is f.

Nothing above is hidden — this is the entire specification. The difficulty is not in the rules, it's in implementing f so that the chain behaves correctly. Figuring out how f can know it has seen the last call is the puzzle. There's no hint for it here.

Encoder

Write a short tinylisp program and turn it into a Puzzle program. Because N grows exponentially with byte length (roughly 256 per extra byte), only very short programs are practical to actually run — that's a property of the language, not a bug in this page.

tinylisp source

Primitives available: quote atom eq car cdr cons cond if lambda label define, arithmetic + - * / mod < > =, and print. Leading NUL bytes in your source will not survive encoding — N can't represent them.

source bytes
N
backticks (2N)
encode a program to see it here

Your interpreter

Implement f below. It will be invoked exactly the way a real Puzzle program invokes it: as the head of a tagged‑template chain, 2N backticks long, N calls total. Two helpers are available inside your code:

f.js

The stub below is deliberately empty. There is no scaffolding for counting calls or detecting the end of the chain — that's the part to design.

Run

Runs the most recently encoded Puzzle program against your current f, by literally constructing f followed by that many backticks and evaluating it — the real JavaScript grammar, not a simulation of it.

Console

— output will appear here —